public boolean IsContinuous(int [] numbers) {
if(numbers == null || numbers.length <5){
return false;
}
for(int i = 0;i< numbers.length - 1;i++){
int min = i;
for(int j = i+1;j< numbers.length;j++){
if(numbers[min] > numbers[j]){
min = j;
}
}
if(min != i){
int temp = numbers[i];
numbers[i] = numbers[min];
numbers[min] = temp;
}
}
//求大小王有几张
int zero_num = 0;
for(int i = 0;i< numbers.length;i++){
if( 0 == numbers[i]){
zero_num ++;
}
}
//找出最大值到最小值的距离
int distance = 0;
for(int i = zero_num;i< numbers.length - 1;i++){
if(numbers[i] == numbers[i+1]){
return false;
}
//计算 如果两个值相差为0 那就是连续的 不是 0 那就GG了
distance += numbers[i+1] - numbers[i] - 1;
}
if(zero_num >= distance){
return true;
}
return false;
}
}