leetcode

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

commit29bc8f52242fc488b2665bb23828395b05d5403e
parent12d3b277506d3df88ee0bf42d4d25383406280b5
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateThu, 25 Apr 2024 10:17:12 +0200

Daily Problem

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

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


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

@@ -0,0 +1,16 @@

class Solution {
public:
int longestIdealString(const string &s, int k) const {
static int dp[256];
int res = 0;
memset(dp, 0x00, sizeof(dp));
for (const char c : s) {
for (int j = c - k; j <= c + k; j++)
dp[c] = max(dp[c], dp[j]);
res = max(res, ++dp[c]);
}
return res;
}
};

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

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

| 2366 | Hard | [Minimum Replacements to Sort the Array](Problems/2366.cpp) |
| 2368 | Medium | [Reachable Nodes With Restrictions](Problems/2368.cpp) |
| 2369 | Medium | [Check if There is a Valid Partition For The Array](Problems/2369.cpp) |
| 2370 | Medium | [Longest Ideal Subsequence](Problems/2370.cpp) |
| 2374 | Medium | [Node With Highest Edge Score](Problems/2374.cpp) |
| 2375 | Medium | [Construct Smallest Number From DI String](Problems/2375.cpp) |
| 2385 | Medium | [Amount of Time for Binary Tree to Be Infected](Problems/2385.cpp) |