• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
October 14, 2024 |470 Views

SDE Sheet - Find median in a stream

  Share   Like
Description
Discussion

This video is part of the Heap section under GFG SDE Sheet.

Given an input stream of N integers. The task is to insert these numbers into a new stream and find the median of the stream formed by each insertion of X to the new stream.

Example 1:

Input: N = 4 X[] = 5,15,1,3 Output: 5 10 5 4 Explanation:Flow in stream : 5, 15, 1, 3 5 goes to stream --> median 5 (5) 15 goes to stream --> median 10 (5,15) 1 goes to stream --> median 5 (5,15,1) 3 goes to stream --> median 4 (5,15,1 3) 

Do check out:-
Problem: https://www.geeksforgeeks.org/problems/find-median-in-a-stream-1587115620/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/
Article Link: https://www.geeksforgeeks.org/median-of-stream-of-running-integers-using-stl/