Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 1769. Minimum Number of Operations to Move All Balls to Each Box
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.
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.