Scramble String
Problem statement
A nonempty string can be recursively split into two nonempty parts; at any split, the two children may either keep their order or swap. Determine whether second can be produced from first by repeating this operation.
Function
isScramble(first: String, second: String) → booleanExamples
Example 1
first = "great"second = "rgeat"return = trueCase 1 exercises the documented deterministic contract.
Example 2
first = "abcde"second = "caebd"return = falseCase 2 exercises the documented deterministic contract.
Example 3
first = "a"second = "a"return = trueCase 3 exercises the documented deterministic contract.
Constraints
1 <= first.length == second.length <= 30.- Both strings contain lowercase English letters.