본문 바로가기
python-algorithm

leetcode 2053. Kth Distinct String in an Array

by 무적김두칠 2022. 3. 21.

1
2
3
4
5
6
7
8
9
class Solution:
    def kthDistinct(self, arr: List[str], k: int-> str:
        kCheck=0
        ans=''
        for i in range(len(arr)):
            if arr.count(arr[i])==1:
                kCheck+=1
                if kCheck==k: ans=arr[i]; break
        return ans                   
cs
반응형

댓글