Available question text
Determine each row's rightmost 1 and treat those positions as requirements to place at or before their row index; greedily for each row i find the nearest row at or below i whose rightmost 1 ≤ i and bring it up with adjacent swaps, summing the distances (or return -1 if impossible).
Related questions
Continue with questions that share topics or the same question type.
- Minimum Number of Flips to Make Binary Grid Palindromic I
Coding
- Minimum Number of Flips to Make Binary Grid Palindromic II
Coding
- Minimum Number of Swaps to Make the Binary String Alternating
Coding
- Maximum Score After Binary Swaps
Coding · Array · Greedy · Heap (Priority Queue)
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 1536. Minimum Swaps to Arrange a Binary Grid
Interview date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source