Skip to content

Commit 7c5f710

Browse files
committed
Fixed sonar
1 parent 9198424 commit 7c5f710

File tree

1 file changed

+5
-2
lines changed
  • src/main/java/g3201_3300/s3213_construct_string_with_minimum_cost

1 file changed

+5
-2
lines changed

src/main/java/g3201_3300/s3213_construct_string_with_minimum_cost/Solution.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ public int minimumCost(String target, String[] words, int[] costs) {
8787
int e = pair.get(1);
8888
dm.putIfAbsent(e, new HashMap<>());
8989
Map<Integer, Integer> qm = dm.get(e);
90-
qm.put(b, qm.getOrDefault(b, Integer.MAX_VALUE));
91-
qm.put(b, Math.min(qm.get(b), costs[i]));
90+
if (qm.containsKey(b)) {
91+
qm.put(b, Math.min(qm.get(b), costs[i]));
92+
} else {
93+
qm.put(b, costs[i]);
94+
}
9295
}
9396
}
9497
}

0 commit comments

Comments
 (0)