Ctrl K

Skip-One Swaps

Easy
You are given two strings first and second, each of length 4. On either string you may repeat this move any number of times: pick positions i and j with j - i = 2 and swap the letters at them. Return True if the strings can be made identical, and False otherwise.
Example 1
first="mark", second="rkma" → True

Swap positions 0 and 2 to get "ramk", then 1 and 3 to get "rkma".

Example 2
first="mark", second="amrk" → False

The letter m sits at an odd position, but second needs it at an even one, which it can never reach.

Constraints
  • len(first) = len(second) = 4
  • Both strings consist of lowercase English letters
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasyShared Start of Words EasyBracket Balance EasyWhere the Fragment Starts EasyLength of the Final Word Easy
loading Python…
Input
first="mark", second="rkma"
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 65 tests on the server, hidden ones included.