We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2aeb8a3 commit 91c918eCopy full SHA for 91c918e
src/main/java/com/fishercoder/solutions/_1057.java
@@ -59,12 +59,10 @@ public int[] assignBikes(int[][] workers, int[][] bikes) {
59
PriorityQueue<int[]> workerBikePairs = treeMap.get(dist);
60
while (!workerBikePairs.isEmpty()) {
61
int[] workerBikePair = workerBikePairs.poll();
62
- if (ans[workerBikePair[0]] == -1) {
63
- if (!assigned[workerBikePair[1]]) {
64
- assigned[workerBikePair[1]] = true;
65
- ans[workerBikePair[0]] = workerBikePair[1];
66
- workersHaveBikes++;
67
- }
+ if (ans[workerBikePair[0]] == -1 && !assigned[workerBikePair[1]]) {
+ assigned[workerBikePair[1]] = true;
+ ans[workerBikePair[0]] = workerBikePair[1];
+ workersHaveBikes++;
68
}
69
70
if (workersHaveBikes == w) {
0 commit comments