We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 95eacb4 commit 86b5612Copy full SHA for 86b5612
solution/2700-2799/2707.Extra Characters in a String/Solution.js
@@ -3,17 +3,17 @@
3
* @param {string[]} dictionary
4
* @return {number}
5
*/
6
-var minExtraChar = function(s, dictionary) {
+var minExtraChar = function (s, dictionary) {
7
const ss = new Set(dictionary);
8
const n = s.length;
9
- const f = new Array(n + 1).fill(0);
+ const f = Array(n + 1).fill(0);
10
for (let i = 1; i <= n; ++i) {
11
f[i] = f[i - 1] + 1;
12
for (let j = 0; j < i; ++j) {
13
- if (ss.has(s.substring(j, i))) {
+ if (ss.has(s.slice(j, i))) {
14
f[i] = Math.min(f[i], f[j]);
15
}
16
17
18
- return f[n];
+ return f[n];
19
};
0 commit comments