Median of Two Sorted Arrays in O(log (m+n))

This problem is labeled Hard... But my approach wasn't. 🚀 Day 79/365 — DSA Challenge Median of Two Sorted Arrays The requirement says: ⚡ Solve in O(log (m+n)) But today... I focused on clarity over optimization 💡 My Approach: 1. Merge both sorted arrays 2. Find the median from the merged array While merging: • Compare elements from both arrays • Add the smaller one • Continue until fully merged Then: If total length is odd → pick middle If even → take average of two middle values ⏱ Time: O(m + n) 📦 Space: O(m + n) What I learned: You don't always need the optimal solution first. A clear solution builds understanding. Optimization can come next. Code 👇 https://lnkd.in/dad5sZfu #DSA #Java #LeetCode #LearningInPublic #Consistency #ProblemSolving

  • text

To view or add a comment, sign in

Explore content categories