一个更简洁、复杂度更低的解法
扑克牌顺子
http://www.nowcoder.com/questionTerminal/762836f4d43d43ca9deb273b3de8e1f4
时间复杂度:O(N)
空间复杂度:O(1)
class Solution { public: bool IsContinuous( vector<int> numbers ) { int maxN=0; int minN=15; int zero=0; for(int n : numbers) { if(n==0) { zero++; continue; } maxN=max(maxN,n); minN=min(minN,n); } return maxN-minN<5&&maxN-minN>3-zero; } };