Median Of Two Sorted Arrays Visualizer & Solution | Rulcode
Loading problem details...
172. Median Of Two Sorted Arrays
Hard
Topics
Companies
Hint
Hints
Understand Before Coding
Visualize This Problem
Open Visualizer
Draw Your Approach
Draw
Example 1:
Input:nums1 = [1,3], nums2 = [2]
Output:2.00000
Explanation:The merged array is [1,2,3]. The total length is 3 (odd), so the median is the middle element at index 1 (0-indexed), which is 2.
Example 2:
Input:nums1 = [1,2], nums2 = [3,4]
Output:2.50000
Explanation:The merged array is [1,2,3,4]. The total length is 4 (even), so the median is the average of the two middle elements at indices 1 and 2 (0-indexed), which are (2 + 3) / 2 = 2.5.