Skip to content

Commit 4c70b0a

Browse files
committed
Runtime: 578 ms (Top 25.39%) | Memory: 72.5 MB (Top 21.92%)
1 parent 3468d45 commit 4c70b0a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

scripts/algorithms/C/Concatenated Words/Concatenated Words.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Runtime: 578 ms (Top 25.39%) | Memory: 72.5 MB (Top 21.92%)
12

23
class Node {
34
val;
@@ -6,7 +7,7 @@ class Node {
67
constructor(val) {
78
this.val = val;
89
}
9-
10+
1011
}
1112
class Trie {
1213
nodes = Array(26);
@@ -21,7 +22,7 @@ class Trie {
2122
node.children[idx] = childNode;
2223
node = childNode;
2324
}
24-
25+
2526
node.isWord = true;
2627
}
2728

@@ -33,15 +34,15 @@ class Trie {
3334
if (!node) {
3435
break;
3536
}
36-
37+
3738
if (node.isWord) {
3839
rslt.push(i-start+1);
3940
}
4041
}
41-
42+
4243
return rslt;
4344
}
44-
45+
4546
getIdx(ch) {
4647
return ch.charCodeAt(0) - "a".charCodeAt(0);
4748
}
@@ -61,7 +62,7 @@ var findAllConcatenatedWordsInADict = function(words) {
6162
}
6263
tr.addWord(words[i]);
6364
}
64-
65+
6566
return rslt;
6667
};
6768

@@ -77,15 +78,15 @@ function check(word, i, trie, dp) {
7778
dp[i] = false;
7879
return false;
7980
}
80-
81+
8182
dp[i] = true;
8283
for (let l of lens) {
8384
if (check(word, i+l, trie, dp)) {
8485
return true;
8586
}
8687
}
87-
88+
8889
dp[i] = false;
89-
90+
9091
return false;
91-
}
92+
}

0 commit comments

Comments
 (0)