Skip to content

Commit 878e262

Browse files
luzhangegonSchiele
authored andcommitted
Update SetCovering.java (egonSchiele#120)
The statesNeeded and finalStations set should be updated after the for loop which finds the bestStation.
1 parent 59ee067 commit 878e262

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

08_greedy_algorithms/java/01_set_covering/src/SetCovering.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ public static void main(String[] args) {
2525
bestStation = station.getKey();
2626
statesCovered = covered;
2727
}
28-
statesNeeded.removeIf(statesCovered::contains);
28+
}
29+
statesNeeded.removeIf(statesCovered::contains);
2930

30-
if (bestStation != null) {
31-
finalStations.add(bestStation);
32-
}
31+
if (bestStation != null) {
32+
finalStations.add(bestStation);
3333
}
3434
}
3535
System.out.println(finalStations); // [ktwo, kone, kthree, kfive]
3636
}
37-
}
37+
}

0 commit comments

Comments
 (0)