We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9359241 commit 2f852a3Copy full SHA for 2f852a3
my-submissions/e2053.py
@@ -0,0 +1,27 @@
1
+class Solution:
2
+ def kthDistinct(self, arr: List[str], k: int) -> str:
3
+ distinct = set()
4
+ notdistinct = set()
5
+
6
+ for s in arr :
7
+ if s in notdistinct :
8
+ continue
9
+ if s in distinct :
10
+ distinct.remove(s)
11
+ notdistinct.add(s)
12
+ else :
13
+ distinct.add(s)
14
15
16
+ if k > len(distinct) :
17
+ return ""
18
19
+ for x in arr :
20
+ if x not in distinct :
21
22
+ k -= 1
23
24
+ if k <= 0 :
25
+ return x
26
27
+ return 'error'
0 commit comments