Ananth B’s Post

🔹 Day 45: Move Zeroes (LeetCode #283) 📌 Problem Statement: Given an integer array nums, move all 0s to the end of it while maintaining the relative order of the non-zero elements. The operation must be done in-place, without making a copy of the array. ✅ My Approach: I used a two-pointer technique — one pointer tracks the position to place the next non-zero element, and the other iterates through the array. Whenever a non-zero element is found, it is swapped with the element at the tracking pointer position. This efficiently pushes all zeroes to the end while keeping the order intact. 📊 Complexity: Time Complexity: O(n) Space Complexity: O(1) ⚡ Submission Stats: Runtime: 3 ms (Beats 20.93%) Memory: 45.96 MB (Beats 86.42%) 💡 Reflection: A clean and efficient in-place array manipulation problem that reinforced the importance of pointer management for space optimization. 🚀 #LeetCode #Java #Array #TwoPointers #100DaysOfCode #Day45

  • graphical user interface

To view or add a comment, sign in

Explore content categories