Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes399downloads
total-characters-in-string-after-transformations-i.json71 linesDownload Raw Back to root
1{2  "id": 3629,3  "name": "total-characters-in-string-after-transformations-i",4  "difficulty": "Medium",5  "link": "https://leetcode.com/problems/total-characters-in-string-after-transformations-i/",6  "date": "2024-10-20",7  "task_description": "You are given a string `s` and an integer `t`, representing the number of **transformations** to perform. In one **transformation**, every character in `s` is replaced according to the following rules: If the character is `'z'`, replace it with the string `\"ab\"`. Otherwise, replace it with the **next** character in the alphabet. For example, `'a'` is replaced with `'b'`, `'b'` is replaced with `'c'`, and so on. Return the **length** of the resulting string after **exactly** `t` transformations. Since the answer may be very large, return it **modulo** `109 + 7`. **Example 1:** **Input:** s = \"abcyy\", t = 2 **Output:** 7 **Explanation:** **First Transformation (t = 1)**: `'a'` becomes `'b'` `'b'` becomes `'c'` `'c'` becomes `'d'` `'y'` becomes `'z'` `'y'` becomes `'z'` String after the first transformation: `\"bcdzz\"` **Second Transformation (t = 2)**: `'b'` becomes `'c'` `'c'` becomes `'d'` `'d'` becomes `'e'` `'z'` becomes `\"ab\"` `'z'` becomes `\"ab\"` String after the second transformation: `\"cdeabab\"` **Final Length of the string**: The string is `\"cdeabab\"`, which has 7 characters. **Example 2:** **Input:** s = \"azbk\", t = 1 **Output:** 5 **Explanation:** **First Transformation (t = 1)**: `'a'` becomes `'b'` `'z'` becomes `\"ab\"` `'b'` becomes `'c'` `'k'` becomes `'l'` String after the first transformation: `\"babcl\"` **Final Length of the string**: The string is `\"babcl\"`, which has 5 characters. **Constraints:** `1 <= s.length <= 105` `s` consists only of lowercase English letters. `1 <= t <= 105`",8  "test_case": [9    {10      "label": "Example 1",11      "input": "s = \"abcyy\", t = 2",12      "output": "7 "13    },14    {15      "label": "Example 2",16      "input": "s = \"azbk\", t = 1",17      "output": "5 "18    }19  ],20  "constraints": [21    "If the character is 'z', replace it with the string \"ab\".",22    "Otherwise, replace it with the next character in the alphabet. For example, 'a' is replaced with 'b', 'b' is replaced with 'c', and so on.",23    "First Transformation (t = 1):\n\n\t\n'a' becomes 'b'\n'b' becomes 'c'\n'c' becomes 'd'\n'y' becomes 'z'\n'y' becomes 'z'\nString after the first transformation: \"bcdzz\"",24    "'a' becomes 'b'",25    "'b' becomes 'c'",26    "'c' becomes 'd'",27    "'y' becomes 'z'",28    "'y' becomes 'z'",29    "String after the first transformation: \"bcdzz\"",30    "Second Transformation (t = 2):\n\t\n'b' becomes 'c'\n'c' becomes 'd'\n'd' becomes 'e'\n'z' becomes \"ab\"\n'z' becomes \"ab\"\nString after the second transformation: \"cdeabab\"",31    "'b' becomes 'c'",32    "'c' becomes 'd'",33    "'d' becomes 'e'",34    "'z' becomes \"ab\"",35    "'z' becomes \"ab\"",36    "String after the second transformation: \"cdeabab\"",37    "Final Length of the string: The string is \"cdeabab\", which has 7 characters.",38    "'a' becomes 'b'",39    "'b' becomes 'c'",40    "'c' becomes 'd'",41    "'y' becomes 'z'",42    "'y' becomes 'z'",43    "String after the first transformation: \"bcdzz\"",44    "'b' becomes 'c'",45    "'c' becomes 'd'",46    "'d' becomes 'e'",47    "'z' becomes \"ab\"",48    "'z' becomes \"ab\"",49    "String after the second transformation: \"cdeabab\"",50    "First Transformation (t = 1):\n\n\t\n'a' becomes 'b'\n'z' becomes \"ab\"\n'b' becomes 'c'\n'k' becomes 'l'\nString after the first transformation: \"babcl\"",51    "'a' becomes 'b'",52    "'z' becomes \"ab\"",53    "'b' becomes 'c'",54    "'k' becomes 'l'",55    "String after the first transformation: \"babcl\"",56    "Final Length of the string: The string is \"babcl\", which has 5 characters.",57    "'a' becomes 'b'",58    "'z' becomes \"ab\"",59    "'b' becomes 'c'",60    "'k' becomes 'l'",61    "String after the first transformation: \"babcl\"",62    "1 <= s.length <= 105",63    "s consists only of lowercase English letters.",64    "1 <= t <= 105"65  ],66  "python_template": "class Solution(object):\n    def lengthAfterTransformations(self, s, t):\n        \"\"\"\n        :type s: str\n        :type t: int\n        :rtype: int\n        \"\"\"\n        ",67  "java_template": "class Solution {\n    public int lengthAfterTransformations(String s, int t) {\n        \n    }\n}",68  "metadata": {69    "func_name": "lengthAfterTransformations"70  }71}