Median Across Sorted Arrays
Updated
Problem statement
You are given an array of individually sorted integer arrays. Return the median of all values across every input array without changing their order.
Empty inner arrays are allowed, but at least one value exists overall. For an even total number of values, return the sum of the two middle values divided by two.
Function
medianOfSortedArrays(arrays: int[][]) → doubleExamples
Example 1
arrays = [[1,3],[2]]return = 2.0The merged order is [1,2,3], whose middle value is two.
Example 2
arrays = [[1,2],[3,4],[]]return = 2.5The two middle values are two and three.
Example 3
arrays = [[-5,-1,7],[0,2,9],[3,4]]return = 2.5Across eight values, the middle pair is two and three.
Constraints
1 <= arrays.length <= 100000- Every inner array is sorted in nondecreasing order.
- The total number of values is between
1and200000. - Values are signed 32-bit integers.
More Google Phone Screen questions
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Maximize Fish over Limited HoursByteDance · PHONE SCREENByteDance interview questions
- Find the Safest Path in a GridAmazon · PHONE SCREEN · ONSITE INTERVIEW
- IPOTekion · PHONE SCREENTekion interview questions
- Smallest Range Covering Elements from K ListsSnap Inc. · PHONE SCREENSnap Inc. interview questions
- Running Medians and PercentilesStackAdapt · PHONE SCREENStackAdapt interview questions
- IPOInMobi · PHONE SCREENInMobi interview questions
- Meeting Rooms IIIBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Running Median of a StreamPeopleStrong · PHONE SCREEN · ONSITE INTERVIEWPeopleStrong interview questions
- Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions