Timeline for Find the third biggest integer of an array
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 27, 2022 at 18:12 | comment | added | qwr | For top k numbers, you can maintain a k-size max-heap. But that is probably not faster in practice for small k. | |
Jan 27, 2022 at 10:41 | comment | added | Matthieu M. |
@Teepeemm: For a generic version of selecting the k-th largest, OP's approach is O(n * k); depending how large k is related to log n , sorting may offer better complexity. Also... this approach has the advantage of being very easy to understand, which is a clear advantage.
|
|
Jan 27, 2022 at 5:21 | history | edited | Sᴀᴍ Onᴇᴌᴀ♦ | CC BY-SA 4.0 |
add line after last fence so the fence doesn't appear within code
|
Jan 27, 2022 at 2:51 | comment | added | Teepeemm |
But sorting is an n log n operation. OP's approach is O(n) .
|
|
Jan 27, 2022 at 2:35 | history | answered | Bens Steves | CC BY-SA 4.0 |