Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 1151. Minimum Swaps to Group All 1's Together
Given a binary array, find the minimum number of swaps required to make all 1's contiguous by grouping them together; this reduces to locating a subarray of length equal to the total number of 1's that contains the fewest zeros (sliding-window pattern).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.