Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc3ac45a

Browse files
committed
Improved task 3213
1 parent8f3e250 commitc3ac45a

File tree

1 file changed

+3
-1
lines changed
  • src/main/java/g3201_3300/s3213_construct_string_with_minimum_cost

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ public int minimumCost(String target, String[] words, int[] costs) {
8686
dp[0] =0;
8787
ACAutomaton.Nodenode =root;
8888
for (inti =1;i <dp.length;i++) {
89-
node =ac.go(node,target.charAt(i -1));
89+
if (node !=null) {
90+
node =ac.go(node,target.charAt(i -1));
91+
}
9092
for (ACAutomaton.Nodetemp =node;
9193
temp !=null &&temp !=root;
9294
temp =ac.getOutput(temp)) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp