In-Place Algorithms for Move Zeroes and Merge Sorted Array

🚀 Day 3/100 – #100DaysOfDSA Another day, more learning, and deeper understanding of in-place algorithms! 🔹 Problems Solved: Move Zeroes Merge Sorted Array 💡 Key Learnings: 👉 Problem 1: Move Zeroes Applied Two Pointer Technique One pointer tracks position for next non-zero element Another pointer iterates through the array Swap only when needed to maintain order ✅ Maintains relative order ✅ In-place (O(1) space) ✅ O(n) Time Complexity 👉 Problem 2: Merge Sorted Array Solved using reverse two-pointer approach Start filling from the end of nums1 (to avoid overwriting elements) Compare elements from nums1 and nums2, and place the larger one at the end ✅ Efficient merge without extra array ✅ O(m + n) Time ✅ In-place solution 🔥 What I learned today: Sometimes solving from the end instead of the beginning makes the problem much simpler and avoids unnecessary complexity. Consistency is building momentum. Day 3 done ✅ #100DaysOfCode #DSA #LeetCode #ProblemSolving #CodingJourney #SoftwareEngineer #JavaScript #TechGrowth #LearningInPublic #Developers

I’m learning it too. Solved merge sorted arrays today. Keep going✨

To view or add a comment, sign in

Explore content categories