Find K Closest Elements
Medium
Sorting & Searching (Misc)
Given a sorted array, an integer k and a target x, print the k elements closest to x in ascending order. Ties are broken by choosing the smaller value.
Constraints
1 <= k <= n <= 10^4
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.