Given an array deliveryTimes, process the values from left to right. After each new delivery time arrives, output the median of all delivery times seen so far.
When the number of seen values is even, use the lower median, meaning the larger value in the lower half after sorting.
Return an array containing the median after each insertion.
Source note: The source only shared a short prompt and one example. FastPrep filled in the explanation and clarified the constraints from that example, especially the lower-median behavior, so the problem is easier to practice. If you find a fuller source, feel free to let us know and we will update it. Thank you! 🦩
deliveryTimes = [5,17,100,11] return = [5,5,17,11]
The sorted prefixes are [5], [5,17], [5,17,100], and [5,11,17,100]. Their lower medians are 5, 5, 17, and 11.
deliveryTimesare processed from left to right.- After each new value is inserted, record the median of all values seen so far.
- When the number of seen values is even, use the lower median: the larger value in the lower half after sorting.
- Return one median for each insertion.
- Maximum System Memory CapacityOA · Seen Jul 2026
- Minimize Effort with EffiBin KitSeen Jul 2026
- Minimum Merge ConflictsOA · Seen Jul 2026
- Currency Conversion RatePHONE SCREEN · Seen Jul 2026
- Number of Islands IIONSITE INTERVIEW · Seen Jul 2026
- Minimum Operations to Make the Integer ZeroSeen Jul 2026
- Create Array Generator ServiceSeen Jul 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jul 2026
public int[] runningDeliveryMedians(int[] deliveryTimes) {
// write your code here
}