Practice Scramble String
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
A string of one character stays unchanged. To scramble a longer string, split it into two nonempty parts, optionally swap the order of those parts, and recursively apply the same process to each part. Given equal-length strings s1 and s2, return whether some choices of splits and swaps can transform s1 into s2.
Source: Scramble String on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
s1 = "great", s2 = "rgeat"
Output
true
# Example 2
Input
s1 = "abcde", s2 = "caebd"
Output
false
# Example 3
Input
s1 = "a", s2 = "a"
Output
true
Constraints
s1.length == s2.length
1 <= s1.length <= 30
s1 and s2 consist of lowercase English letters.
Related LeetCode Problems
Practice more problems similar to Scramble String.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.