# [2053\. Kth Distinct String in an Array](https://leetcode.com/problems/kth-distinct-string-in-an-array/) :::spoiler Hint ```cpp= ``` ::: :::spoiler Solution ```cpp= class Solution { public: string kthDistinct(vector<string>& arr, int k) { unordered_map<string, int> m; for (const auto& str : arr) m[str]++; for (const auto& num : arr) { if (m[num] == 1 && !--k) return num; } return ""; } }; ``` - T: $O(n)$ - S: $O(n)$ :::
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up