标签:数组 bool 思路 等于 space sort 之间 desc bsp
题目描述
class Solution { public: bool IsContinuous( vector<int> numbers ) { if(numbers.size() == 0){ return false; } sort(numbers.begin(),numbers.end()); int zeroNum = 0; int space = 0; int i ; for(i = 0;i < numbers.size();++i){ if(numbers[i] != 0){ break; } ++zeroNum; } for(i;i < numbers.size() - 1;++i){ if(numbers[i + 1] == numbers[i]){ return false; } space += numbers[i + 1] - numbers[i] - 1; } if(space <= zeroNum){ return true; } return false; } };
标签:数组 bool 思路 等于 space sort 之间 desc bsp
原文地址:http://www.cnblogs.com/dingxiaoqiang/p/7497361.html