Available question text
Given a binary string where '1' marks a ball in a box, compute for each index the minimum total number of adjacent moves required to move all balls to that box — equivalently the sum of distances from that index to every '1'. The challenge is to avoid O(n^2) distance summation and use cumulative counts/distances (prefix/suffix) to get an O(n) solution.
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 1769. Minimum Number of Operations to Move All Balls to Each Box
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source