commit 8cff7477f0f8e680eecea787a813db39875fe56d
parent ef6377bb9bbd8b9bcd6e390af70e03e53184fbf0
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Mon, 3 Jun 2024 10:33:30 +0200
1 Random Problem
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/Problems/2260.cpp b/Problems/2260.cpp
@@ -0,0 +1,15 @@
+class Solution {
+ public:
+ int minimumCardPickup(const vector<int> &cards) const {
+ static int pos[1000001];
+ int res = INT_MAX;
+
+ memset(pos, 0xFF, sizeof(pos));
+ for (int i = 0; i < size(cards); i++) {
+ if (pos[cards[i]] != -1) res = min(res, i - pos[cards[i]]);
+ pos[cards[i]] = i;
+ }
+
+ return res != INT_MAX ? res + 1 : -1;
+ }
+};
diff --git a/README.md b/README.md
@@ -1075,6 +1075,7 @@ for solving problems.
| 2246 | Hard | [Longest Path With Different Adjacent Characters](Problems/2246.cpp) |
| 2251 | Hard | [Number of Flowers in Full Bloom](Problems/2251.cpp) |
| 2257 | Medium | [Count Unguarded Cells in the Grid](Problems/2257.cpp) |
+| 2260 | Medium | [Minimum Consecutive Cards to Pick Up](Problems/2260.cpp) |
| 2264 | Easy | [Largest 3-Same-Digit Number in String](Problems/2264.cpp) |
| 2265 | Medium | [Count Nodes Equal to Average of Subtree](Problems/2265.cpp) |
| 2265 | Medium | [Count Nodes Equal to Average of Subtree](Problems/2265.cpp) |