FastPrepScramble String
Problems/Scramble String

Scramble String

Expedia logoExpedia● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported task identifies this algorithmic exercise. The executable interface, bounds, deterministic tie rules, and examples are the documented practice contract.

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) → boolean

Examples

Example 1

first = "great"second = "rgeat"return = true

Case 1 exercises the documented deterministic contract.

Example 2

first = "abcde"second = "caebd"return = false

Case 2 exercises the documented deterministic contract.

Example 3

first = "a"second = "a"return = true

Case 3 exercises the documented deterministic contract.

Constraints

  • 1 <= first.length == second.length <= 30.
  • Both strings contain lowercase English letters.

More Expedia problems

  • Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
  • Balanced NumbersOA · Seen Aug 2026
  • REST API: Discounted PriceOA · Seen Aug 2026
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public boolean isScramble(String first, String second) {
        // Write your code here.
    }

}
Checking account…