Scramble String
Hard
Topics
We can scramble a string s by recursively splitting it into two non-empty substrings and optionally swapping them, then scrambling each part. Given two strings s (as s) and t, return true if t is a scrambled string of s.
Example 1
Input: s = "great", t = "rgeat" Output: true
Example 2
Input: s = "abcde", t = "caebd" Output: false
Example 3
Input: s = "a", t = "a" Output: true
Constraints
- s.length == t.length
- 1 <= s.length <= 8
- s and t consist of lowercase English letters.
Run ⌘' · Submit ⌘⏎