deno.land / x / masx200_leetcode_test@10.6.5 / remove-duplicate-letters / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function smallestSubsequence(s: string): string { const ans: string[] = [" "]; const d: Set<string> = new Set(); Array.prototype.forEach.call(s, (c, i) => { if (!d.has(c)) { const t = s.slice(i); for ( let a = ans[ans.length - 1]; a > c && t.indexOf(a) + 1; a = ans[ans.length - 1] ) { const temp = ans[ans.length - 1]; d.delete(temp); ans.pop(); } ans.push(c); d.add(c); } }); return ans.slice(1).join("");}export default smallestSubsequence;
masx200_leetcode_test

Version Info

Tagged at
a year ago