Divide & Conquer: LeetCode 912 Sort an Array with Merge Sort

🚀 Day 8 of My LeetCode Journey — Divide & Conquer Today’s problem: Sort an Array (LeetCode 912) 💡 Approach: Merge Sort (Recursive) Instead of using built-in sorting, I implemented a recursive solution using the Divide & Conquer technique. 👉 Break the array into halves 👉 Recursively sort each half 👉 Merge the sorted halves using a helper function Creating a separate merge function to combine two sorted arrays made the logic clean and modular. 🧠 What I Learned: Recursion becomes powerful when combined with Divide & Conquer Breaking problems into smaller pieces simplifies complex logic Writing helper functions improves code readability and reuse ⚡ Complexity: ⏱️ Time: O(n log n) 📦 Space: O(n) 🔥 This problem felt like a step up from basic sorting (Bubble/Selection). Understanding how efficient sorting actually works under the hood was a great experience. Thanks to Namaste DSA and Akshay Saini 🚀 for the guidance Day 9 loading… 💪 #LeetCode #DataStructures #Algorithms #CodingJourney #100DaysOfCode #SoftwareEngineering #Programming #InterviewPrep #JavaScript #CodingLife #TechGrowth #ProblemSolving #Developers #LearnToCode #MergeSort #Recursion #DivideAndConquer #NamasteDSA

To view or add a comment, sign in

Explore content categories