File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {string } s
3
+ * @return {number }
4
+ */
5
+ var numberOfSubstrings = function ( s ) {
6
+
7
+ } ;
8
+
9
+ const example1 = numberOfSubstrings ( 'abcabc' ) ; // 10
10
+ const example2 = numberOfSubstrings ( 'aaacb' ) ; // 3
11
+ const example3 = numberOfSubstrings ( 'abc' ) ; // 1
12
+
13
+ console . log ( example1 ) ;
14
+ console . log ( example2 ) ;
15
+ console . log ( example3 ) ;
16
+
17
+ // var numberOfSubstrings = function(s) {
18
+ // return solve(s, 3) - solve(s, 2)
19
+ // };
20
+
21
+ // var solve = function(word, n) {
22
+ // const vowels = new Set(['a', 'b', 'c'])
23
+ // const freqMap = new Map()
24
+ // let l = 0, r = 0, result = 0
25
+
26
+ // while (r < word.length) {
27
+ // if (vowels.has(word[r])) {
28
+ // freqMap.set(word[r], (freqMap.get(word[r]) || 0) + 1)
29
+ // } else {
30
+ // freqMap.clear()
31
+ // l = r + 1
32
+ // }
33
+
34
+ // while (freqMap.size > n) {
35
+ // freqMap.set(word[l], freqMap.get(word[l]) - 1)
36
+ // if (freqMap.get(word[l]) === 0) {
37
+ // freqMap.delete(word[l])
38
+ // }
39
+ // l++
40
+ // }
41
+
42
+ // result += r - l + 1
43
+ // r++
44
+ // }
45
+
46
+ // return result
47
+ // }
You can’t perform that action at this time.
0 commit comments