Loading...
Is this your company?
How to get the k smallest element in O(klogk) time
Anonymous
do you mean O(nlogn)? where n is size of array?
To find k smallest elements among n elements in total, efficient implementation takes O(n logk), using a binary heap of size k.
I think it was nlogn, otherwise if k = 1, O(1) seems impossible for unsorted array
Check out your Company Bowl for anonymous work chats.
Get actionable career advice tailored to you by joining more bowls.
Stay ahead in opportunities and insider tips by following your dream companies.
Get personalized job recommendations and updates by starting your searches.