391 views
2 votes
2 votes
Can anyone please explain how to find “ i “ smallest elements from an array whose elements are distinct

Please use max heap to explain the working

input : n distinct elements

output : i smallest elements

1 Answer

Best answer
5 votes
5 votes

Using max heap we can find i smallest elements in O( n * log i ) time

this method is very popular in coding interviews

selected by

Related questions

1 votes
1 votes
1 answer
1