标签:self 决定 title 16px 统计 fga 处理 += code
1 # -*- coding:utf-8 -*-
2 class Solution:
3 def IsContinuous(self, numbers):
4 # write code here
5 if len(numbers) < 1:
6 return False
7 # 统计0的个数
8 numberOfZero = 0
9 for i in numbers:
10 if i==0:
11 numberOfZero +=1
12 # 排序
13 numbers = sorted(numbers)
14 #统计间隔
15 numbersOfGap = 0
16 for i in range(numberOfZero+1,len(numbers)): # 从第二个非零处起
17 if numbers[i]-numbers[i-1]>1:
18 numbersOfGap += numbers[i]-numbers[i-1]-1
19 if numbers[i]==numbers[i-1]: # 排序后的数组存在对子
20 return False
21 return True if numberOfZero>=numbersOfGap else False
22
23
24
标签:self 决定 title 16px 统计 fga 处理 += code
原文地址:https://www.cnblogs.com/shuangcao/p/12808042.html