FPEvalDataset/LeetCodeProblem
0305
1{2 "id": 3595,3 "name": "rearrange_k_substrings_to_form_target_string",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/rearrange-k-substrings-to-form-target-string/",6 "date": "2024-11-17 00:00:00",7 "task_description": "You are given two strings `s` and `t`, both of which are anagrams of each other, and an integer `k`. Your task is to determine whether it is possible to split the string `s` into `k` equal-sized substrings, rearrange the substrings, and concatenate them in _any order_ to create a new string that matches the given string `t`. Return `true` if this is possible, otherwise, return `false`. An **anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, using all the original letters exactly once. A **substring** is a contiguous non-empty sequence of characters within a string. **Example 1:** **Input:** s = \"abcd\", t = \"cdab\", k = 2 **Output:** true **Explanation:** Split `s` into 2 substrings of length 2: `[\"ab\", \"cd\"]`. Rearranging these substrings as `[\"cd\", \"ab\"]`, and then concatenating them results in `\"cdab\"`, which matches `t`. **Example 2:** **Input:** s = \"aabbcc\", t = \"bbaacc\", k = 3 **Output:** true **Explanation:** Split `s` into 3 substrings of length 2: `[\"aa\", \"bb\", \"cc\"]`. Rearranging these substrings as `[\"bb\", \"aa\", \"cc\"]`, and then concatenating them results in `\"bbaacc\"`, which matches `t`. **Example 3:** **Input:** s = \"aabbcc\", t = \"bbaacc\", k = 2 **Output:** false **Explanation:** Split `s` into 2 substrings of length 3: `[\"aab\", \"bcc\"]`. These substrings cannot be rearranged to form `t = \"bbaacc\"`, so the output is `false`. **Constraints:** `1 <= s.length == t.length <= 2 * 105` `1 <= k <= s.length` `s.length` is divisible by `k`. `s` and `t` consist only of lowercase English letters. The input is generated such that `s` and `t` are anagrams of each other.",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "s = \"abcd\", t = \"cdab\", k = 2",12 "output": "true "13 },14 {15 "label": "Example 2",16 "input": "s = \"aabbcc\", t = \"bbaacc\", k = 3",17 "output": "true "18 },19 {20 "label": "Example 3",21 "input": "s = \"aabbcc\", t = \"bbaacc\", k = 2",22 "output": "false "23 }24 ],25 "private_test_cases": [26 {27 "input": [28 "\"nhxity\"",29 "\"tnihxy\"",30 631 ],32 "output": true33 },34 {35 "input": [36 "\"r\"",37 "\"r\"",38 139 ],40 "output": true41 },42 {43 "input": [44 "\"lpwwrswrtcfxnuudnl\"",45 "\"wwrclnufpstxdnwulr\"",46 347 ],48 "output": false49 },50 {51 "input": [52 "\"vcbmf\"",53 "\"vmbfc\"",54 155 ],56 "output": false57 },58 {59 "input": [60 "\"btwialsxbj\"",61 "\"lsixabwtjb\"",62 563 ],64 "output": false65 },66 {67 "input": [68 "\"hkebrpbzczxddgsuydzq\"",69 "\"rqdkzdhpszbbucyegdxz\"",70 171 ],72 "output": false73 },74 {75 "input": [76 "\"upgvuoyo\"",77 "\"ugovupyo\"",78 879 ],80 "output": true81 },82 {83 "input": [84 "ap",85 "pa",86 287 ],88 "output": true89 },90 {91 "input": [92 "cewbaivdehl",93 "bvdlheiacwe",94 1195 ],96 "output": true97 },98 {99 "input": [100 "vuxkgjtsuuxz",101 "ukxgxjvuutzs",102 6103 ],104 "output": false105 }106 ],107 "haskell_template": "isPossibleToRearrange :: String -> String -> Int -> Bool\nisPossibleToRearrange s t k ",108 "ocaml_template": "let isPossibleToRearrange (s: string) (t: string) (k: int) : bool = ",109 "scala_template": "def isPossibleToRearrange(s: String,t: String,k: Int): Boolean = { \n \n}",110 "java_template": "class Solution {\n public boolean isPossibleToRearrange(String s, String t, int k) {\n \n }\n}",111 "python_template": "class Solution(object):\n def isPossibleToRearrange(self, s, t, k):\n \"\"\"\n :type s: str\n :type t: str\n :type k: int\n :rtype: bool\n \"\"\"\n "112}