Skip to content

Commit 495b769

Browse files
committed
Create README - LeetHub
1 parent e5c8e8c commit 495b769

File tree

1 file changed

+42
-0
lines changed
  • 2825-make-string-a-subsequence-using-cyclic-increments

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<h2><a href="https://leetcode.com/problems/make-string-a-subsequence-using-cyclic-increments/">2825. Make String a Subsequence Using Cyclic Increments</a></h2><h3>Medium</h3><hr><div><p>You are given two <strong>0-indexed</strong> strings <code>str1</code> and <code>str2</code>.</p>
2+
3+
<p>In an operation, you select a <strong>set</strong> of indices in <code>str1</code>, and for each index <code>i</code> in the set, increment <code>str1[i]</code> to the next character <strong>cyclically</strong>. That is <code>'a'</code> becomes <code>'b'</code>, <code>'b'</code> becomes <code>'c'</code>, and so on, and <code>'z'</code> becomes <code>'a'</code>.</p>
4+
5+
<p>Return <code>true</code> <em>if it is possible to make </em><code>str2</code> <em>a subsequence of </em><code>str1</code> <em>by performing the operation <strong>at most once</strong></em>, <em>and</em> <code>false</code> <em>otherwise</em>.</p>
6+
7+
<p><strong>Note:</strong> A subsequence of a string is a new string that is formed from the original string by deleting some (possibly none) of the characters without disturbing the relative positions of the remaining characters.</p>
8+
9+
<p>&nbsp;</p>
10+
<p><strong class="example">Example 1:</strong></p>
11+
12+
<pre><strong>Input:</strong> str1 = "abc", str2 = "ad"
13+
<strong>Output:</strong> true
14+
<strong>Explanation:</strong> Select index 2 in str1.
15+
Increment str1[2] to become 'd'.
16+
Hence, str1 becomes "abd" and str2 is now a subsequence. Therefore, true is returned.</pre>
17+
18+
<p><strong class="example">Example 2:</strong></p>
19+
20+
<pre><strong>Input:</strong> str1 = "zc", str2 = "ad"
21+
<strong>Output:</strong> true
22+
<strong>Explanation:</strong> Select indices 0 and 1 in str1.
23+
Increment str1[0] to become 'a'.
24+
Increment str1[1] to become 'd'.
25+
Hence, str1 becomes "ad" and str2 is now a subsequence. Therefore, true is returned.</pre>
26+
27+
<p><strong class="example">Example 3:</strong></p>
28+
29+
<pre><strong>Input:</strong> str1 = "ab", str2 = "d"
30+
<strong>Output:</strong> false
31+
<strong>Explanation:</strong> In this example, it can be shown that it is impossible to make str2 a subsequence of str1 using the operation at most once.
32+
Therefore, false is returned.</pre>
33+
34+
<p>&nbsp;</p>
35+
<p><strong>Constraints:</strong></p>
36+
37+
<ul>
38+
<li><code>1 &lt;= str1.length &lt;= 10<sup>5</sup></code></li>
39+
<li><code>1 &lt;= str2.length &lt;= 10<sup>5</sup></code></li>
40+
<li><code>str1</code> and <code>str2</code> consist of only lowercase English letters.</li>
41+
</ul>
42+
</div>

0 commit comments

Comments
 (0)