Back to Questions

Find K Closest Elements (Heaps)

148.2K viewsAsked at Meta
Medium

Question Explain

Given a sorted array, a target value $x$, and an integer $k$, find the $k$ closest elements to $x$ in the array. Use a Max-Heap to maintain the $k$ closest elements.

Start Trying This Question Simulation

Practice answering orally or with text to get instant AI feedback.

Practice with This Question