Trains the technique from
LeetCode 2839Check if Strings Can be Made Equal With Operations IThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
Two dials each show exactly four lowercase letters, given as s1 and s2.
One turn on a dial picks two of its positions that are two apart and swaps the letters in them. So on a dial reading positions 0, 1, 2, 3, a turn swaps positions 0 and 2, or swaps positions 1 and 3. Either dial may be turned, any number of times.
Return true when the two dials can be made to read the same, and false otherwise.
Example 1
Turning the first dial at positions 0 and 2 gives "cbad", and turning it again at positions 1 and 3 gives "cdab".
Example 2
Positions 2 and 3 hold different letters on the two dials, and no turn can move a letter from an even position to an odd one.
Example 3
Both pairs hold the same two letters on each dial, so the turns can bring the readings together.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def dials_can_match(s1: str, s2: str) -> bool:public boolean dialsCanMatch(String s1, String s2)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.