leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE | |
commit | 7eb221874b996f34ef2038e5a61f53bcf613e768 |
parent | 9212a087df08586dd7c8c525297ad0271cbe2087 |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Thu, 5 Dec 2024 15:43:17 +0100 |
Daily Problem
Diffstat:A | Problems/2337.cpp | | | +++++++++++++++++++++++ |
M | README.md | | | + |
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/Problems/2337.cpp b/Problems/2337.cpp
@@ -0,0 +1,23 @@
class Solution {
public:
bool canChange(const string &start, const string &target) const {
const int n = size(start);
int i = 0, j = 0;
while (i < n || j < n) {
while (i < n && start[i] == '_')
i++;
while (j < n && target[j] == '_')
j++;
if (i == n || j == n) return i == n && j == n;
if (start[i] != target[j]) return false;
if (start[i] == 'R' ? i > j : i < j) return false;
i++, j++;
}
return true;
}
};
diff --git a/README.md b/README.md
@@ -1269,6 +1269,7 @@ reference and a base for solving problems.
| 2328 | Hard | [Number of Increasing Paths in a Grid](Problems/2328.cpp) |
| 2331 | Easy | [Evaluate Boolean Binary Tree](Problems/2331.cpp) |
| 2336 | Medium | [Smallest Number in Infinite Set](Problems/2336.cpp) |
| 2337 | Medium | [Move Pieces to Obtain a String](Problems/2337.cpp) |
| 2342 | Medium | [Max Sum of a Pair With Equal Sum of Digits](Problems/2342.cpp) |
| 2343 | Medium | [Query Kth Smallest Trimmed Number](Problems/2343.cpp) |
| 2348 | Medium | [Number of Zero-Filled Subarrays](Problems/2348.cpp) |