Skip to content

Commit 91c918e

Browse files
refactor 1057
1 parent 2aeb8a3 commit 91c918e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/main/java/com/fishercoder/solutions/_1057.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@ public int[] assignBikes(int[][] workers, int[][] bikes) {
5959
PriorityQueue<int[]> workerBikePairs = treeMap.get(dist);
6060
while (!workerBikePairs.isEmpty()) {
6161
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-
}
62+
if (ans[workerBikePair[0]] == -1 && !assigned[workerBikePair[1]]) {
63+
assigned[workerBikePair[1]] = true;
64+
ans[workerBikePair[0]] = workerBikePair[1];
65+
workersHaveBikes++;
6866
}
6967
}
7068
if (workersHaveBikes == w) {

0 commit comments

Comments
 (0)