Skip to content

Commit 5507e18

Browse files
authored
Update Solution.java
1 parent a95468a commit 5507e18

File tree

1 file changed

+0
-5
lines changed
  • src/main/java/g1701_1800/s1769_minimum_number_of_operations_to_move_all_balls_to_each_box

1 file changed

+0
-5
lines changed

src/main/java/g1701_1800/s1769_minimum_number_of_operations_to_move_all_balls_to_each_box/Solution.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,26 @@
44

55
public class Solution {
66
public int[] minOperations(String boxes) {
7-
87
int countFromLeft = 0;
98
int countFromRight = 0;
109
int moves = 0;
1110
int[] result = new int[boxes.length()];
12-
1311
for (char c : boxes.toCharArray()) {
1412
moves += countFromLeft;
1513
if (c == '1') {
1614
countFromLeft++;
1715
}
1816
}
19-
2017
for (int i = boxes.length() - 1; i >= 0; i--) {
2118
char c = boxes.charAt(i);
2219
result[i] = moves;
23-
2420
if (c == '1') {
2521
countFromLeft--;
2622
countFromRight++;
2723
}
2824
moves -= countFromLeft;
2925
moves += countFromRight;
3026
}
31-
3227
return result;
3328
}
3429
}

0 commit comments

Comments
 (0)