题解 | #扑克牌顺子#
扑克牌顺子
http://www.nowcoder.com/practice/762836f4d43d43ca9deb273b3de8e1f4
import java.util.*;
public class Solution {
public boolean IsContinuous(int [] numbers) {
HashSet<Integer> set = new HashSet<Integer>();
for(int i : numbers){
if(i != 0 && set.contains(i)){
return false;
}
set.add(i);
}
set.remove(0);
List<Integer> list = new ArrayList<Integer>(set);
Collections.sort(list);
if(list.get(list.size() - 1) - list.get(0) <= 4){
return true;
}
return false;
}
}