FastPrepRunning Medians
Problems/Running Medians

Running Medians

Microsoft logoMicrosoft● HardNEW GRADONSITE INTERVIEW

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Microsoft Data Scientist internship report asks for a list median and follows up by adding numbers one at a time. Returning the median after every prefix, the even-length convention, interface, bounds, and tolerance are conventional enrichment that consolidates the base and follow-up.

Given an integer array nums, process its values from left to right. After each insertion, return the median of all values seen so far.

For an even number of values, the median is the average of the two middle values. Return one median for every prefix of nums.

Function

runningMedians(nums: int[]) → double[]

Examples

Example 1

nums = [5,15,1,3]return = [5.0,10.0,5.0,4.0]

The sorted prefixes have medians 5, 10, 5, and 4.

Example 2

nums = [2,2,2]return = [2.0,2.0,2.0]

Every prefix consists only of the value 2.

Constraints

  • 1 <= nums.length <= 100000
  • -10^9 <= nums[i] <= 10^9
  • Results use absolute tolerance 1e-12

More Microsoft Onsite Interview questions

  • Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Top K With a Deterministically Noisy Comparator (MLE)Mercor · ONSITE INTERVIEWMercor interview questions
  • Meeting Rooms III: Most Booked RoomGoogle · ONSITE INTERVIEWGoogle interview questions
  • Find the Safest Path in a GridAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Employee Free TimeIDFC Bank · ONSITE INTERVIEWIDFC Bank interview questions
  • Minimum Refueling StopsUber · ONSITE INTERVIEWUber interview questions
  • Sliding Window MedianNotion · ONSITE INTERVIEWNotion interview questions
  • Order Matching on ExecuteSquarepoint Capital · ONSITE INTERVIEWSquarepoint Capital interview questions
  • Sliding Window MedianBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Running Median of a StreamPeopleStrong · PHONE SCREEN · ONSITE INTERVIEWPeopleStrong interview questions
  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions

Interview reports that mention this question

  • Microsoft AI/ML Intern Interviews: 114 Experiences (Part 1 of 2)

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public double[] runningMedians(int[] nums) {
      // Write your code here.
    }

}
Checking account…