A distinct string is a string that is present only once in an array.

Given an array of strings arr, and an integer k, return the kth distinct string present in arr. If there are fewer than k distinct strings, return an empty string "".

Note that the strings are considered in the order in which they appear in the array.

&nbsp;
Example 1:

Input: arr = ["d","b","c","b","c","a"], k = 2
Output: "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. 


Example 2:

Input: arr = ["aaa","aa","a"], k = 1
Output: "aaa"
Explanation:
All strings in arr are distinct, so the 1st string "aaa" is returned.


Example 3:

Input: arr = ["a","b","a"], k = 3
Output: ""
Explanation:
The only distinct string is "b". Since there are fewer than 3 distinct strings, we return an empty string "".


&nbsp;
Constraints:


	1 &lt;= k &lt;= arr.length &lt;= 1000
	1 &lt;= arr[i].length &lt;= 5
	arr[i] consists of lowercase English letters.


class Solution:
    def kthDistinct(self, arr: List[str], k: int) -> str:
        hash_map = {}
        for string in arr:
            hash_map[string] = hash_map.get(string, 0) + 1
        for string in arr:
            if hash_map[string] == 1:
                k -= 1
                if k == 0:
                    return string
        return ""
class Solution {
    public String kthDistinct(String[] arr, int k) {
        Map<String,Integer> map=new HashMap<>();
        
        for(String s:arr){
            
            if(map.containsKey(s)) map.put(s,map.get(s)+1);
             else map.put(s,1);
        }
		int i=0;
        for(String s:arr){
            if(map.get(s)==1 && ++i==k){
                
                    return s;
                } 
                 
        }
        return "";
        
    }
}
class Solution 
{
public:
    string kthDistinct(vector<string>& arr, int k) 
    {
        unordered_map<string,int>m;
        for(int i=0;i<arr.size();i++)
        {
            m[arr[i]]++;
        }
        for(int i=0;i<arr.size();i++)
        {
            if(m[arr[i]]==1)
            {
                k--;
            }
            if(k==0 && m[arr[i]]==1)
            {
                return arr[i];
            }
        }
        return "";
    }
};
var kthDistinct = function(arr, k) {
    const map = {} // used for arr occurences
    const distinctArr = [] // store the distinct values (only appearing once)
    
	// increment the occurence to the map
    arr.forEach(letter => map[letter] = map[letter] + 1 || 1)
    
	// store all the distinct values in order
    for (let [key, val] of Object.entries(map)) 
        if (val == 1) distinctArr.push(key)
    
	// return the key or empty string
    return distinctArr[k-1] || ""
};
~``
Kth Distinct String in an Array