Available question text
Given a binary string, find the minimum number of adjacent swaps needed to move all 1s to the right (0s to the left); this equals the number of inversions (pairs where a '1' appears before a '0'), which can be computed in linear time for n up to 1e5.
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 2938. Separate Black and White Balls
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source