
Move Zeroes - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
void moveZeroes(vector<int>& nums){
int wideIndex = 0;
for(int i = 0; i < nums.size(); i++){
if(nums[i] != 0){
swap(nums[i], nums[wideIndex]);
wideIndex++;
}
}
}
'Problem set' 카테고리의 다른 글
[LeetCode] Sort-Array-By-Parity-ii (0) | 2022.08.26 |
---|---|
[LeetCode] Find Pivot Index (0) | 2022.08.26 |
[백준] 1967 트리의 지름 (0) | 2021.02.20 |
[백준] 1167 트리의 지름 (0) | 2021.02.20 |
[백준] 11725 트리의 부모 찾기 (0) | 2021.02.20 |