← All problemsSign in

87. Scramble String

LeetCodeStringDynamic ProgrammingOpen on judge ↗

We can scramble a string s to get a string t using the following algorithm: - If the length of the string is 1, stop. - If the length of the string is > 1, do the following: - Split the string into two non-empty substrings at a random index, i.e., if the string is s, divide it to x and y where s = x + y. - Randomly decide to swap the two substrings or to keep them in the same order. i.e., afte

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start