Skip to content

Commit 95565df

Browse files
authored
Create 283.cpp
1 parent 82fb652 commit 95565df

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

leetcode/cpp/Two Pointer/283.cpp

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

0 commit comments

Comments
 (0)