Dsa
Sliding Window
Easy
Kth Largest in Sliding Window
Given an array of integers and a window size k, return the k-th largest element for each sliding window. Input the array size followed by the elements of the array and the window size in one line (e.g., '5 1 2 3 4 5 2'). Output the k-th largest element for each window.
Example:
Input:
8 1 5 2 6 8 3 1 4 2 3
Output:
5 6 6 4 3
Key concepts
sliding_windowheapkth_largest
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now