leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2053.cpp (331B)


0 class Solution { 1 public: 2 string kthDistinct(const vector<string> &arr, int k) const { 3 unordered_map<string, int> um; 4 5 for (const auto &s : arr) 6 um[s]++; 7 for (const auto &s : arr) { 8 if (um[s] > 1) continue; 9 if (!--k) return s; 10 } 11 12 return ""; 13 } 14 };