move-zeroes
1.0.0
Move Zeroes
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1
#include <bits/stdc++.h>
2
3
using namespace
std;
4
5
class
Solution
6
{
7
public
:
8
void
moveZeroes
(vector<int>& nums)
9
{
10
int
index = 0;
11
for
(
int
el: nums)
12
if
(el != 0)
13
nums[index++] = el;
14
while
(index < (
int
)nums.size())
15
nums[index++] = 0;
16
}
17
};
18
19
int
main
()
20
{
21
vector<int> nums = {0,1,0,3,12};
22
Solution
().
moveZeroes
(nums);
23
for
(
int
el: nums)
24
cout << el <<
" "
;
25
cout <<
'\n'
;
26
return
0;
27
}
Solution
Definition
main.cpp:6
Solution::moveZeroes
void moveZeroes(vector< int > &nums)
Definition
main.cpp:8
main
int main()
Definition
main.cpp:19
main.cpp
Generated by
1.9.8