You are given a binary string boxes of length n, where boxes[i] is '0' if the box at index i is empty, and '1' if it contains a ball.
In one operation, you can move j to an adjacent box at index j + 1 or j - 1.
Return an array answer of length n, where answer[i] is the minimum number of operations required to move all the balls to the box at index i.
Constraints:
n boxes.length
n
boxes[i] is either '0' or '1'
You are given a binary string boxes of length n, where boxes[i] is '0' if the box at index i is empty, and '1' if it contains a ball.
In one operation, you can move j to an adjacent box at index j + 1 or j - 1.
Return an array answer of length n, where answer[i] is the minimum number of operations required to move all the balls to the box at index i.
Constraints:
n boxes.length
n
boxes[i] is either '0' or '1'