标签:ber 自己 color tor god 题目 cto 扑克牌 begin
class Solution { public: bool IsContinuous( vector<int> numbers ) { if (numbers.size() == 0) return false; sort(numbers.begin(), numbers.end()); int zeroCnt = 0; //0的个数 int index = 0; //第一个非0数字 while (numbers[index] == 0) { index++; zeroCnt++; } int sumDiff = 0; for (; index < numbers.size()-1; index++) { int diff = numbers[index + 1] - numbers[index]-1; if (diff == -1 ) { return false; //有对子 } sumDiff += diff; if (sumDiff > zeroCnt) { return false; } } return true; } };
标签:ber 自己 color tor god 题目 cto 扑克牌 begin
原文地址:http://www.cnblogs.com/xiuxiu55/p/6642492.html