Practice Make String a Subsequence Using Cyclic Increments
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given two 0-indexed strings str1 and str2. In an operation, you select a set of indices in str1, and for each index i in the set, increment str1[i] to the next character cyclically. That is 'a' becomes 'b', 'b' becomes 'c', and so on, and 'z' becomes 'a'. Return true if it is possible to make str2 a subsequence of str1 by performing the operation at most once, and false otherwise. Note: 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.
Source: Make String a Subsequence Using Cyclic Increments on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
str1 = "abc", str2 = "ad"
true
# Example 2
str1 = "zc", str2 = "ad"
true
# Example 3
str1 = "ab", str2 = "d"
false
Constraints
Related LeetCode Problems
Practice more problems similar to Make String a Subsequence Using Cyclic Increments.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.