Skip to content

Commit 3794274

Browse files
authored
Update 1316-distinct-echo-substrings.js
1 parent ae206e3 commit 3794274

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

1316-distinct-echo-substrings.js

-23
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,3 @@ const distinctEchoSubstrings = function (text) {
1818
return set.size
1919
}
2020

21-
// another
22-
23-
/**
24-
* @param {string} s
25-
* @return {string}
26-
*/
27-
const removeDuplicateLetters = function(s) {
28-
const last = {}
29-
for (let i = 0; i < s.length; i++) last[s.charAt(i)] = i
30-
const added = {}
31-
const stack = []
32-
for (let i = 0; i < s.length; i++) {
33-
const char = s.charAt(i)
34-
if (added[char]) continue
35-
while (stack.length && char < stack[stack.length - 1] && last[stack[stack.length - 1]] > i) {
36-
added[stack[stack.length - 1]] = false
37-
stack.pop()
38-
}
39-
stack.push(char)
40-
added[char] = true
41-
}
42-
return stack.join('')
43-
}

0 commit comments

Comments
 (0)