A distinct string is one that appears exactly once in an array. Given an array of strings arr and an integer k, return the k-th distinct string in the order the strings appear in arr. If there are fewer than k distinct strings, return an empty string "".
A distinct string is one that appears exactly once in an array. Given an array of strings arr and an integer k, return the k-th distinct string in the order the strings appear in arr. If there are fewer than k distinct strings, return an empty string "".
Example 1:
Input: {"arr":["d","b","c","b","c","a"],"k":2}
Output: a
Constraints:
1≤k≤arr.length≤1000
1≤arr[i].length≤5
arr[i] consists of lowercase English letters.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"arr":["d","b","c","b","c","a"],"k":2}
Pass 1 counts every string. Pass 2 walks arr in order and counts down k = 2 on strings seen exactly once.