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;
}
}
leetcode 846. Hand of Straights
最新推荐文章于 2024-06-29 23:22:04 发布