leetcode

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

commita5cd13cc92be06b5820dde677f39411665c3c6a9
parent50f0daddb5054bf4eb982e04f7fc88c4043093e1
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateMon, 5 Aug 2024 21:37:20 +0200

Daily Problem

Diffstat:
AProblems/2053.cpp|+++++++++++++++
MREADME.md|+

2 files changed, 16 insertions(+), 0 deletions(-)


diff --git a/Problems/2053.cpp b/Problems/2053.cpp

@@ -0,0 +1,15 @@

class Solution {
public:
string kthDistinct(const vector<string> &arr, int k) const {
unordered_map<string, int> um;
for (const auto &s : arr)
um[s]++;
for (const auto &s : arr) {
if (um[s] > 1) continue;
if (!--k) return s;
}
return "";
}
};

diff --git a/README.md b/README.md

@@ -1059,6 +1059,7 @@ for solving problems.

| 2045 | Hard | [Second Minimum Time to Reach Destination](Problems/2045.cpp) |
| 2049 | Medium | [Count Nodes With the Highest Score](Problems/2049.cpp) |
| 2050 | Hard | [Parallel Courses III](Problems/2050.cpp) |
| 2053 | Easy | [Kth Distinct String in an Array](Problems/2053.cpp) |
| 2058 | Medium | [Find the Minimum and Maximum Number of Nodes Between Critical Points](Problems/2058.cpp) |
| 2063 | Medium | [Vowels of All Substrings](Problems/2063.cpp) |
| 2064 | Medium | [Minimized Maximum of Products Distributed to Any Store](Problems/2064.cpp) |