leetcode

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

commit ff690b3d271ab3c8e131cca2e1f22de8fb7d205d
parent 9e42f609f804bb22d3929b5f7f4622b60f1ca6da
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Tue, 10 Sep 2024 20:27:38 +0200

1 Random Problem

Diffstat:
AProblems/2825.cpp | 15+++++++++++++++
MREADME.md | 1+
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/Problems/2825.cpp b/Problems/2825.cpp @@ -0,0 +1,15 @@ +class Solution { + public: + bool canMakeSubsequence(string str1, string str2) { + int i = 0, j = 0; + + while (i < size(str1) && j < size(str2)) { + if (str1[i] == str2[j] || str1[i] + 1 == str2[j] || (str1[i] == 'z' && str2[j] == 'a')) { + i++, j++; + } else + i++; + } + + return j == size(str2); + } +}; diff --git a/README.md b/README.md @@ -1294,6 +1294,7 @@ for solving problems. | 2807 | Medium | [Insert Greatest Common Divisors in Linked List](Problems/2807.cpp) | | 2812 | Medium | [Find the Safest Path in a Grid](Problems/2812.cpp) | | 2816 | Medium | [Double a Number Represented as a Linked List](Problems/2816.cpp) | +| 2825 | Medium | [Make String a Subsequence Using Cyclic Increments](Problems/2825.cpp) | | 2840 | Medium | [Check if Strings Can be Made Equal With Operations II](Problems/2840.cpp) | | 2849 | Medium | [Determine if a Cell Is Reachable at a Given Time](Problems/2849.cpp) | | 2856 | Medium | [Minimum Array Length After Pair Removals](Problems/2856.cpp) |