# [LeetCode]#2053. Kth Distinct String in an Array

`Input: arr = ["d","b","c","b","c","a"], k = 2Output: "a"Explanation:The only distinct strings in arr are "d" and "a"."d" appears 1st, so it is the 1st distinct string."a" appears 2nd, so it is the 2nd distinct string.Since k == 2, "a" is returned.`
`Input: arr = ["aaa","aa","a"], k = 1Output: "aaa"Explanation:All strings in arr are distinct, so the 1st string "aaa" is returned.`
`Input: arr = ["a","b","a"], k = 3Output: ""Explanation:The only distinct string is "b". Since there are fewer than 3 distinct strings, we return an empty string "".`
1. Counter arr
2. Find only distinct strings
3. return the order is match k
`from collections import Counterclass Solution:    def kthDistinct(self, arr, k):        cnt=Counter(arr)        for key,v in cnt.items():            if v==1:                k-=1            if k==0:                return key        return ""`

--

--

--

## More from Fatboy Slim

Interesting in any computer science.

Love podcasts or audiobooks? Learn on the go with our new app.

## Fatboy Slim

Interesting in any computer science.