Skip to content

Commit 4d73417

Browse files
authored
Create 1698-number-of-distinct-substrings-in-a-string.js
1 parent 452fcea commit 4d73417

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @param {string} s
3+
* @return {number}
4+
*/
5+
const countDistinct = function(s) {
6+
const set = new Set()
7+
for(let i = 0, len = s.length; i < len; i++) {
8+
for(let j = i + 1; j <= len; j++) {
9+
set.add(s.slice(i, j))
10+
}
11+
}
12+
13+
return set.size
14+
};

0 commit comments

Comments
 (0)