Skip to content

Commit d696285

Browse files
authored
Update minimum-swaps-to-group-all-1s-together-ii.cpp
1 parent 816d960 commit d696285

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

C++/minimum-swaps-to-group-all-1s-together-ii.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Solution {
66
int minSwaps(vector<int>& nums) {
77
const int w = count(cbegin(nums), cend(nums), 1);
88
int result = w, cnt = w;
9-
for (int i = 0; i < size(nums) * 2; ++i) {
9+
for (int i = 0; i < size(nums) + (w - 1); ++i) {
1010
if (i >= w) {
1111
cnt += nums[(i - w) % size(nums)];
1212
}

0 commit comments

Comments
 (0)