Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Consider if there are more than <code>k</code> obstacles. Can the <code>k + 1<sup>th</sup></code> obstacle ever be the answer to any query?
Maintain a max heap of size <code>k</code>, thus heap will contain minimum element at the top in that queue.
Solve with full IDE support and test cases
Remove top element and insert new element from input array if current max is larger than this.