We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7a18121 commit 46a2880Copy full SHA for 46a2880
solution/2700-2799/2707.Extra Characters in a String/README_EN.md
@@ -211,6 +211,30 @@ impl Solution {
211
}
212
```
213
214
+#### JavaScript
215
+
216
+```js
217
+/**
218
+ * @param {string} s
219
+ * @param {string[]} dictionary
220
+ * @return {number}
221
+ */
222
+var minExtraChar = function (s, dictionary) {
223
+ const ss = new Set(dictionary);
224
+ const n = s.length;
225
+ const f = Array(n + 1).fill(0);
226
+ for (let i = 1; i <= n; ++i) {
227
+ f[i] = f[i - 1] + 1;
228
+ for (let j = 0; j < i; ++j) {
229
+ if (ss.has(s.slice(j, i))) {
230
+ f[i] = Math.min(f[i], f[j]);
231
+ }
232
233
234
+ return f[n];
235
+};
236
+```
237
238
<!-- tabs:end -->
239
240
<!-- solution:end -->
0 commit comments