Available question text
Interpret allowedSwaps as edges of an undirected graph: any indices in the same connected component can be arbitrarily permuted, so to minimize Hamming distance you should, per component, match as many source values to target values as possible using multiset counts. The answer is the sum over components of (component size − number of matched values).
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
No company association
Leetcode 1722. Minimize Hamming Distance After Swap Operations
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source