-
Notifications
You must be signed in to change notification settings - Fork 0
/
283.cpp
40 lines (37 loc) · 848 Bytes
/
283.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <vector>
#include <set>
#include <map>
using namespace std;
void moveZeroes(vector<int>& nums) {
int count = 0;
int size = nums.size();
for (int i = 0; i < nums.size(); i++) {
if (nums[i] == 0) {
nums.erase(nums.begin() + i);
nums.push_back(0);
i--;
count++;
}
if(count > size) {
break;
}
}
return;
}
int main() {
vector<int> test_arr;
test_arr.push_back(0);
test_arr.push_back(0);
test_arr.push_back(1);
test_arr.push_back(1);
test_arr.push_back(0);
test_arr.push_back(0);
test_arr.push_back(2);
test_arr.push_back(3);
moveZeroes(test_arr);
for (int i = 0; i < test_arr.size(); i++) {
printf("--%d--momoqingiqng\n", test_arr[i]);
}
return 0;
}