find the smallest K elements of a given list
Anonymous
keep a max heap with k elements and iterate over the array add an element and then remove the max element in the heap repeat until the array has ended then the max heap represents the smallest K elements
Check out your Company Bowl for anonymous work chats.