Approach Explanation o(〃^▽^〃)o
- I used a pointer ptr to track where the next non‑zero should be placed.
- I scanned the array from left to right.
- Whenever I found a non‑zero, copied it to the position at ptr and moved ptr forward.
- After placing all non‑zeros, I filled the remaining positions with zeroes.
- This way, all non‑zeros stayed in their original order, and all zeroes were pushed to the end
Method Used: (〜 ̄▽ ̄)〜
- Two‑phase approach
- Pointer tracking
- In‑place modification
- Stable order
- Efficient traversal

Top comments (0)