-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMove Zeroes.cpp
More file actions
44 lines (23 loc) · 811 Bytes
/
Copy pathMove Zeroes.cpp
File metadata and controls
44 lines (23 loc) · 811 Bytes
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
41
42
43
44
/*
problem link :https://leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/567/
problem name: Move Zeroes
status: accepted
author : mohand sakr
** */
class Solution {
public:
void moveZeroes(vector<int>& nums) {
int len=nums.size();
int index=0;
for(int i=0;i<len;i++){
if(nums[i]){
int temp= nums[i];
nums[index]= temp;
++index;
}
}
for(int i=index;i<len;i++){
nums[i]=0;
}
}
};