Skip to content

Commit 7437980

Browse files
Added solution
1 parent b3be7de commit 7437980

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

move_zeros.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
void moveZeroes(vector<int>& nums) {
4+
5+
int j = 0;
6+
7+
for(int num : nums){
8+
if(num != 0){
9+
nums[j++] = num;
10+
}
11+
}
12+
13+
for(; j<nums.size(); j++){
14+
nums[j] = 0;
15+
}
16+
}
17+
};

0 commit comments

Comments
 (0)