Grokking 75: Top Coding Interview Questions
Ask Author
Back to course home

0% completed

Median of Two Sorted Arrays (hard)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

Given two sorted arrays, nums1 and nums2 of different sizes in the ascending order, return the median of two sorted arrays after merging them.

The median is the middle value in an ordered set, or the average of the two middle values if the set has an even number of elements.

Examples

  1. Example 1:

    • Input: [1, 3, 5] and [2, 4, 6]
    • Expected Output: 3.5
    • Justification: When merged, the array becomes [1, 2, 3, 4, 5, 6]. The median is the average of the middle two values, (3 + 4) / 2 = 3.5.
  2. Example 2:

    • Input:

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible