2053-kth-distinct-string-in-an-array

DevGod
Vtuber
/** * @param {string[]} arr * @param {number} k * @return {string} */var kthDistinct = function(arr, k) { let myMap = _.countBy(arr); let keys = Object.keys(myMap).filter( (key) => myMap[key] === 1) return keys[k-1] !== undefined ? keys[k-1] : "";};
class Solution: def kthDistinct(self, arr: List[str], k: int) -> str: myMap = Counter(arr) arr = [key for key, value in myMap.items() if value <= 1] return "" if len(arr)-k < 0 else arr[k-1]