Available question text
Given two equal-length strings of only 'x' and 'y', compute the minimum number of swaps between the strings (swap s1[i] with s2[j]) to make them identical or return -1 if impossible. Key idea: count mismatches of type "s1='x', s2='y'" and "s1='y', s2='x'"; pair same-type mismatches (one swap per pair) and handle any two opposite leftovers with two swaps, otherwise it's impossible if total mismatches is odd.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Google
Leetcode 1247. Minimum Swaps to Make Strings Equal
Reported Nov 22, 2024 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View source