Median of Two Sorted Arrays — LeetCode #4 (Hard)
The Problem Given two sorted arrays, return the median of all their elements combined, in logarithmic time. Example Input: nums1 = [1,3], nums2 = [2] …
Tech news from the best sources
The Problem Given two sorted arrays, return the median of all their elements combined, in logarithmic time. Example Input: nums1 = [1,3], nums2 = [2] …
TL;DR Single-pass hash map lookup: store each number's index as you go, check for the complement before storing. O(n) time, O(n) space. The Problem Gi…