(This question is a variation of the LeetCode question 703. Kth Largest Element in a Stream. If you haven't completed that question yet, it is recommended to solve it first.)
You are given a permutation arr of the integers from 1 to n (each integer appears exactly once), and an integer k. For each prefix of arr of length i, where i ranges [k, n] inclusive, find the greatest element among the first i elements.
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
Output
Expected