start. You want them to spell goal instead. In one move you may swap any two tiles.
Both strings use exactly the same letters, just possibly in a different order. Return the smallest number of moves that turns start into goal.start="fade", goal="defa" → 2
Swapping letters 0 and 2 gives "dafe", then swapping letters 1 and 3 gives "defa": two swaps, and one is not enough.
start="abba", goal="baab" → 2
Swap letters 0 and 1 to get "baba", then letters 2 and 3 to get "baab".
start="cab", goal="cab" → 0
a–fgoal is a rearrangement of startstart="fade", goal="defa"
2
Run checks the first 3 tests in your browser. Submit checks all 46 tests on the server, hidden ones included.