2053. Kth Distinct String in an Array

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2053

class Solution:
    def kthDistinct(self, arr: List[str], k: int) -> str:
        counter = Counter(arr)
        for v in arr:
            if counter[v] == 1:
                k -= 1
                if k == 0:
                    return v
        return ''