Johnson Controls OA 2024 | Minimum Number of Operations to Move All Balls to Each Box | Prefix Sum

Question · Posted Jun 2026

Problem Statement You are given a binary string boxes where: '1' represents a box containing a ball. '0' represents an empty box. In one operation, you can move a ball from a box to an adjacent box. For every box i, determine the minimum number of operations required to move all balls to box i. Return an integer array answer where: answer[i] = minimum operations required to move all balls to box i Example 1 Input boxes = "110" Output ...

The full answer & interview discussion are available to premium members.

Log in Create a free account