Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes402downloads
make-string-a-subsequence-using-cyclic-increments.json35 linesDownload Raw Back to root
1{2  "id": 3018,3  "name": "make-string-a-subsequence-using-cyclic-increments",4  "difficulty": "Medium",5  "link": "https://leetcode.com/problems/make-string-a-subsequence-using-cyclic-increments/",6  "date": "2023-08-05",7  "task_description": "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. **Example 1:** ``` **Input:** str1 = \"abc\", str2 = \"ad\" **Output:** true **Explanation:** Select index 2 in str1. Increment str1[2] to become 'd'. Hence, str1 becomes \"abd\" and str2 is now a subsequence. Therefore, true is returned. ``` **Example 2:** ``` **Input:** str1 = \"zc\", str2 = \"ad\" **Output:** true **Explanation:** Select indices 0 and 1 in str1. Increment str1[0] to become 'a'. Increment str1[1] to become 'd'. Hence, str1 becomes \"ad\" and str2 is now a subsequence. Therefore, true is returned. ``` **Example 3:** ``` **Input:** str1 = \"ab\", str2 = \"d\" **Output:** false **Explanation:** In this example, it can be shown that it is impossible to make str2 a subsequence of str1 using the operation at most once. Therefore, false is returned. ``` **Constraints:** `1 <= str1.length <= 105` `1 <= str2.length <= 105` `str1` and `str2` consist of only lowercase English letters.",8  "test_case": [9    {10      "label": "Example 1",11      "input": "str1 = \"abc\", str2 = \"ad\"",12      "output": "true "13    },14    {15      "label": "Example 2",16      "input": "str1 = \"zc\", str2 = \"ad\"",17      "output": "true "18    },19    {20      "label": "Example 3",21      "input": "str1 = \"ab\", str2 = \"d\"",22      "output": "false "23    }24  ],25  "constraints": [26    "1 <= str1.length <= 105",27    "1 <= str2.length <= 105",28    "str1 and str2 consist of only lowercase English letters."29  ],30  "python_template": "class Solution(object):\n    def canMakeSubsequence(self, str1, str2):\n        \"\"\"\n        :type str1: str\n        :type str2: str\n        :rtype: bool\n        \"\"\"\n        ",31  "java_template": "class Solution {\n    public boolean canMakeSubsequence(String str1, String str2) {\n        \n    }\n}",32  "metadata": {33    "func_name": "canMakeSubsequence"34  }35}