class Solution {
public boolean isNStraightHand(int[] hand, int W) {
PriorityQueue<Integer> minHeap = new PriorityQueue<>();
for(int i : hand){
minHeap.add(i);
}
while(minHeap.size() != 0) {
int start = minHeap.poll();
for(int j = 1; j < W; j++){
if(minHeap.remove(start + j)) {
continue;
}
else {
return false;
}
}
}
return true;
}
}
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交