There is an unsorted array of size n.
Given a key k find m nearest elements to k.
Array : -10, -50, 20, 17, 80.
key k :20
m : 2
Answer 17, -10.
Solution : Find k closest numbers in an unsorted array
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, Amazon and Microsoft Test Serieses.