class Solution {
public:
bool IsContinuous( vector<int> numbers ) {
if(numbers.empty()) return false;
set<int> s;
for(int num: numbers){
if(num != 0){
if(s.find(num) != s.end()) return false;
s.emplace(num);
}
}
int gap = *max_element(s.begin(), s.end()) - *min_element(s.begin(), s.end());
return gap <= 4;
}
};
# -*- coding:utf-8 -*-
class Solution:
def IsContinuous(self, numbers):
# write code here
if not numbers:
return False
s = set()
for num in numbers:
if num == 0:
continue
if num in s:
return False;
s.add(num)
return max(s) - min(s) <= 4