Median of Two Sorted Arrays
Updated
Problem statement
Given two sorted integer arrays nums1 and nums2, return the median of the two arrays as if they were merged.
Your algorithm must run in O(log(min(nums1.length, nums2.length))) time.
Function
findMedianSortedArrays(nums1: int[], nums2: int[]) → doubleExamples
Example 1
nums1 = [1,3]nums2 = [2]return = 2.0Merging the two arrays gives [1,2,3]. Its middle value is 2, so that is the median.
Example 2
nums1 = [1,2]nums2 = [3,4]return = 2.5The middle values are 2 and 3, so the median is their average.
Constraints
0 <= nums1.length, nums2.length <= 10^5.1 <= nums1.length + nums2.length <= 2 * 10^5.-10^9 <= nums1[i], nums2[i] <= 10^9.- Both arrays are sorted in nondecreasing order.
More Airbnb Online Assessment questions
- Bouncing DiagonalsOA · Seen Dec 2026
- Count Numbers Not Equal to the First TwoOA · Seen Dec 2026
- Garden Sprinkler PlacementOA · Seen Dec 2026
- Theme Park Shuttle Wait TimeOA · Seen Dec 2026
- Count Card Duel RoundsOA · Seen Nov 2026
- Count Lamps Lighting Each PointOA · Seen Nov 2026
- Simulate Orchard Rot SpreadOA · Seen Nov 2026
- Sort Adjacent PairsOA · Seen Nov 2026
- In-Memory File SystemOA · Seen Nov 2026
- Task Management SystemOA · Seen Nov 2026
Similar questions at other companies
- Minimum BeautyBloomberg LP · OABloomberg LP interview questions
- Minimum Operations to Make a SubsequenceGoogle · OAGoogle interview questions
- Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
- Sliding Window MedianAuxoAI · OA
- Maximum Barbell WeightVirtu Financial · OAVirtu Financial interview questions
- Maximum Non-Decreasing Array LengthVisa · OAVisa interview questions
- Minimum Cost to Make Array EqualWalmart · OAWalmart interview questions
- Maximize Array Beauty After DeletionsPoint72 · OAPoint72 interview questions
- Maximum Barbell WeightSalesforce · OASalesforce interview questions
- Data ReorganizationGoldman Sachs · OAGoldman Sachs interview questions
Airbnb interview experiences
- Airbnb OA · November 2026
- Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
- Airbnb Intern Phone Interviews: 21 Experiences (Part 7 of 7)
- Airbnb Intern OA and Phone Screens: 17 Experiences (Part 6 of 7)
- Airbnb Intern OA and Onsite Rounds: 16 Experiences (Part 5 of 7)
- Airbnb Intern OA, Diplomacy Game: 19 Experiences (Part 4 of 7)