题解 | #扑克牌顺子#
扑克牌顺子
https://www.nowcoder.com/practice/762836f4d43d43ca9deb273b3de8e1f4
bitmap
#include <climits> class Solution { public: bool IsContinuous( vector<int> numbers ) { int bit = 0; int _min = INT_MAX, _max = 0; for(auto&& i: numbers) { if(i == 0) continue; _min = min(_min, i); _max = max(_max, i); if(bit & (1 << i)) return false; bit |= 1 << i; } return _max - _min < 5; } };