string kthDistinct(vector<string>& arr, int k) {
unordered_map<string, int> m;
for (auto &s : arr)
++m[s];
//Frome here
for (auto &s : arr)
if (m[s] == 1 && --k == 0)
return s;
return "";
//to here
}
Especially in this part for (auto &s : arr) if (m[s] == 1 && --k == 0) return s;