We are given a stream of integers. We have to find median of the last K elements of the stream.
In other words
Constraints:
$$$0$$$ $$$\leq$$$ nums $$$\leq$$$ $$$10^6$$$, nums is the integer given in the stream.
K $$$\neq$$$ $$$0$$$ , atleast K elements have been given in the stream.
Refer to this comment for better understanding.