FastPrepMedian of Two Sorted Arrays
Problems/Median of Two Sorted Arrays

Median of Two Sorted Arrays

Expedia logoExpedia● HardNEW GRADONSITE INTERVIEW

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The median objective and both linear and logarithmic approaches match the linked source task at about99%.

Given two sorted integer arrays nums1 and nums2, return the median of the two arrays as if they were merged.

First describe a linear merge-based method. Then implement a method that takes O(1 + log(min(nums1.length, nums2.length) + 1)) time. This bound includes the constant-time case when one array is empty.

Function

findMedianSortedArrays(nums1: int[], nums2: int[]) → double

Examples

Example 1

nums1 = [1,3]nums2 = [2]return = 2.0

The conceptual merged order is [1,2,3], whose middle value is 2.

Example 2

nums1 = [1,2]nums2 = [3,4]return = 2.5

The middle values are 2 and 3, so the median is their average.

Constraints

  • 0 <= nums1.length <= 1000 and 0 <= nums2.length <= 1000.
  • At least one array is nonempty.
  • -1000000 <= nums1[i], nums2[i] <= 1000000.
  • Both arrays are sorted in nondecreasing order.

More Expedia Onsite Interview questions

  • Scramble StringONSITE INTERVIEW · Seen Sep 2026
  • Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
  • Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
  • Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
  • Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
  • Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
  • Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
  • Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
  • Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
  • Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024

Similar questions at other companies

  • Russian Doll EnvelopesGoogle · ONSITE INTERVIEWGoogle interview questions
  • K-th Element of Two Sorted ArraysFlipkart · ONSITE INTERVIEW
  • Allocate Minimum PagesAmazon · ONSITE INTERVIEW
  • Minimum Processing Speed with Multiple RidersDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • Russian Doll EnvelopesInMobi · ONSITE INTERVIEWInMobi interview questions
  • Median of Two Sorted ArraysRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Median of Two Sorted ArraysMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Split Array Largest SumBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Median of Two Sorted ArraysJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
  • Search a Row- and Column-Sorted MatrixByteDance · ONSITE INTERVIEWByteDance interview questions

Interview reports that mention this question

  • Expedia New Grad SDE Oldest Loops: 4 Experiences (Part 3 of 3)

Expedia interview experiences

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public double findMedianSortedArrays(int[] nums1, int[] nums2) {
      // Write your code here.
    }
}
Checking account…