Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
haoel committed Nov 4, 2015
1 parent f874fde commit 9b15c6a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion algorithms/cpp/moveZeroes/moveZeroes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Solution {
* We have two pointers to travel the array, assume they named `p1` and `p2`.
*
* 1) `p1` points the tail of current arrays without any ZEROs.
* 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.
*
* Then we can just simply move the item from `p2` to `p1`.
*
Expand All @@ -80,6 +80,7 @@ class Solution {
nums[p1++] = nums[p2];
}

//set ZERO for rest items
while ( p1<nums.size() ) nums[p1++] = 0;
}

Expand Down

0 comments on commit 9b15c6a

Please sign in to comment.