FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 3024,3 "name": "string-transformation",4 "difficulty": "Hard",5 "link": "https://leetcode.com/problems/string-transformation/",6 "date": "2023-09-03",7 "task_description": "You are given two strings `s` and `t` of equal length `n`. You can perform the following operation on the string `s`: Remove a **suffix** of `s` of length `l` where `0 < l < n` and append it at the start of `s`. For example, let `s = 'abcd'` then in one operation you can remove the suffix `'cd'` and append it in front of `s` making `s = 'cdab'`. You are also given an integer `k`. Return _the number of ways in which _`s` _can be transformed into _`t`_ in **exactly** _`k`_ operations._ Since the answer can be large, return it **modulo** `109 + 7`. **Example 1:** ``` **Input:** s = \"abcd\", t = \"cdab\", k = 2 **Output:** 2 **Explanation:** First way: In first operation, choose suffix from index = 3, so resulting s = \"dabc\". In second operation, choose suffix from index = 3, so resulting s = \"cdab\". Second way: In first operation, choose suffix from index = 1, so resulting s = \"bcda\". In second operation, choose suffix from index = 1, so resulting s = \"cdab\". ``` **Example 2:** ``` **Input:** s = \"ababab\", t = \"ababab\", k = 1 **Output:** 2 **Explanation:** First way: Choose suffix from index = 2, so resulting s = \"ababab\". Second way: Choose suffix from index = 4, so resulting s = \"ababab\". ``` **Constraints:** `2 <= s.length <= 5 * 105` `1 <= k <= 1015` `s.length == t.length` `s` and `t` consist of only lowercase English alphabets.",8 "test_case": [9 {10 "label": "Example 1",11 "input": "s = \"abcd\", t = \"cdab\", k = 2",12 "output": "2 "13 },14 {15 "label": "Example 2",16 "input": "s = \"ababab\", t = \"ababab\", k = 1",17 "output": "2 "18 }19 ],20 "constraints": [21 "Remove a suffix of s of length l where 0 < l < n and append it at the start of s.\n\tFor example, let s = 'abcd' then in one operation you can remove the suffix 'cd' and append it in front of s making s = 'cdab'.",22 "2 <= s.length <= 5 * 105",23 "1 <= k <= 1015",24 "s.length == t.length",25 "s and t consist of only lowercase English alphabets."26 ],27 "python_template": "class Solution(object):\n def numberOfWays(self, s, t, k):\n \"\"\"\n :type s: str\n :type t: str\n :type k: int\n :rtype: int\n \"\"\"\n ",28 "java_template": "class Solution {\n public int numberOfWays(String s, String t, long k) {\n \n }\n}",29 "metadata": {30 "func_name": "numberOfWays"31 }32}