class Solution {
public boolean isContinuous(int [] numbers) {
//1.判断是否为空
if(numbers==null || numbers.length<1){
return false;
}
Arrays.sort(numbers);
// System.out.println(Arrays.toString(numbers));
int numbersOfZero=0;//0的个数
int numbersOfGap=0;//间隔
//1.
for(int i=0;i<numbers.length;i++){
if(numbers[i]==0){
numbersOfZero++;
}
}
//
int small=numbersOfZero;
int big=small+1;// 为什么要设置 small 和zero从不是0 的位置开始遍历
while(big<numbers.length){
if(numbers[small]==numbers[big]){//有顺子
return false;
}
numbersOfGap+=numbers[big]-numbers[small]-1;
small=big;
big++;
}
// System.out.println(" gap"+ numbersOfGap +" numbersOfZero "+ numbersOfZero);
return numbersOfGap > numbersOfZero ? false :true;
}
}