Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes399downloads
lexicographically-smallest-string-after-substring-operation.json40 linesDownload Raw Back to root
1{2  "id": 2828,3  "name": "lexicographically-smallest-string-after-substring-operation",4  "difficulty": "Medium",5  "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-substring-operation/",6  "date": "2023-06-04",7  "task_description": "Given a string `s` consisting of lowercase English letters. Perform the following operation: Select any non-empty substring then replace every letter of the substring with the preceding letter of the English alphabet. For example, 'b' is converted to 'a', and 'a' is converted to 'z'. Return the **lexicographically smallest** string **after performing the operation**. **Example 1:** **Input:** s = \"cbabc\" **Output:** \"baabc\" **Explanation:** Perform the operation on the substring starting at index 0, and ending at index 1 inclusive. **Example 2:** **Input:** s = \"aa\" **Output:** \"az\" **Explanation:** Perform the operation on the last letter. **Example 3:** **Input:** s = \"acbbc\" **Output:** \"abaab\" **Explanation:** Perform the operation on the substring starting at index 1, and ending at index 4 inclusive. **Example 4:** **Input:** s = \"leetcode\" **Output:** \"kddsbncd\" **Explanation:** Perform the operation on the entire string. **Constraints:** `1 <= s.length <= 3 * 105` `s` consists of lowercase English letters",8  "test_case": [9    {10      "label": "Example 1",11      "input": "s = \"cbabc\"",12      "output": "\"baabc\" "13    },14    {15      "label": "Example 2",16      "input": "s = \"aa\"",17      "output": "\"az\" "18    },19    {20      "label": "Example 3",21      "input": "s = \"acbbc\"",22      "output": "\"abaab\" "23    },24    {25      "label": "Example 4",26      "input": "s = \"leetcode\"",27      "output": "\"kddsbncd\" "28    }29  ],30  "constraints": [31    "Select any non-empty substring then replace every letter of the substring with the preceding letter of the English alphabet. For example, 'b' is converted to 'a', and 'a' is converted to 'z'.",32    "1 <= s.length <= 3 * 105",33    "s consists of lowercase English letters"34  ],35  "python_template": "class Solution(object):\n    def smallestString(self, s):\n        \"\"\"\n        :type s: str\n        :rtype: str\n        \"\"\"\n        ",36  "java_template": "class Solution {\n    public String smallestString(String s) {\n        \n    }\n}",37  "metadata": {38    "func_name": "smallestString"39  }40}