A string can be scrambled by recursively splitting it into two non-empty parts at any index, optionally swapping the two parts, and scrambling each part the same way. Given two strings s1 and s2 of the same length, return true if s2 is a scrambled string of s1.
A string can be scrambled by recursively splitting it into two non-empty parts at any index, optionally swapping the two parts, and scrambling each part the same way. Given two strings s1 and s2 of the same length, return true if s2 is a scrambled string of s1.
Example 1:
Input: {"s1":"great","s2":"rgeat"}
Output: true
Constraints:
s1.length=s2.length
1≤s1.length≤30
s1 and s2 consist of lowercase English letters.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"s1":"great","s2":"rgeat"}
A scramble splits a string into two non-empty parts, may swap them, and scrambles each part again. Is "rgeat" reachable from "great" this way?