Skip to content

Commit

Permalink
Improved task 3213
Browse files Browse the repository at this point in the history
  • Loading branch information
javadev committed Jul 15, 2024
1 parent 8f3e250 commit c3ac45a
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ public int minimumCost(String target, String[] words, int[] costs) {
dp[0] = 0;
ACAutomaton.Node node = root;
for (int i = 1; i < dp.length; i++) {
node = ac.go(node, target.charAt(i - 1));
if (node != null) {
node = ac.go(node, target.charAt(i - 1));
}
for (ACAutomaton.Node temp = node;
temp != null && temp != root;
temp = ac.getOutput(temp)) {
Expand Down

0 comments on commit c3ac45a

Please sign in to comment.