1 parent f874fde commit 9b15c6aCopy full SHA for 9b15c6a
algorithms/cpp/moveZeroes/moveZeroes.cpp
@@ -62,7 +62,7 @@ class Solution {
62
* We have two pointers to travel the array, assume they named `p1` and `p2`.
63
*
64
* 1) `p1` points the tail of current arrays without any ZEROs.
65
- * 2) `p2` points the head of the reset array which skips the ZEROs.
+ * 2) `p2` points the head of the rest array which skips the ZEROs.
66
67
* Then we can just simply move the item from `p2` to `p1`.
68
@@ -80,6 +80,7 @@ class Solution {
80
nums[p1++] = nums[p2];
81
}
82
83
+ //set ZERO for rest items
84
while ( p1<nums.size() ) nums[p1++] = 0;
85
86
0 commit comments