class Solution {
public:
bool IsContinuous( vector<int> numbers ) {
/*
1,排序,
if(max == 0) return true;
if(没有0) 看是不是递增数列
2, 统计0的个数,如果0的个数<gap,说明ok
gap就是相邻之间的差
*/
int len = numbers.size();
sort(numbers.begin(), numbers.end());
if (numbers[len - 1] == 0) {
return true;
}
int cntZeroNum = 0, gap = 0;
for (int i = 0; i < len - 1; i++) {
if (numbers[i] == 0){
cntZeroNum++;
continue;
}
if (numbers[i] == numbers[i+1]) {
return false;
}
gap += numbers[i+1] - numbers[i] - 1;
}
return (gap <= cntZeroNum);
}
};