标签:
1 class Solution { 2 public: 3 4 bool IsContinuous( vector<int> numbers ) { 5 if(numbers.size()==0) 6 return false; 7 sort(numbers.begin(),numbers.end()); 8 int zero=0,small=0,big=0; 9 int gap=0; 10 while(zero<numbers.size()&&numbers[zero]==0) 11 zero++; 12 small=zero,big=small+1; 13 while(big<numbers.size()) 14 { 15 if(numbers[small]==numbers[big]) 16 return false; 17 gap+=numbers[big]-numbers[small]-1; 18 small=big; 19 big++; 20 21 } 22 return gap<=zero?true:false; 23 24 } 25 };
标签:
原文地址:http://www.cnblogs.com/daocaorenblog/p/5417965.html