Skip to content

Commit ef7ed29

Browse files
authored
Clean up comments in k_least_numbers.cpp
Removed detailed comments about methods for finding the smallest k numbers.
1 parent 3e9762f commit ef7ed29

1 file changed

Lines changed: 0 additions & 15 deletions

File tree

src/3_Stack_Queue/k_least_numbers.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,6 @@
33
*
44
* This program finds the smallest 'k' numbers from a given list of numbers.
55
* It demonstrates three modern C++ implementations:
6-
*
7-
* 1. Simple Sort Method:
8-
* - Sorts the entire list and then takes the first k numbers.
9-
* - Time Complexity: O(n log n)
10-
*
11-
* 2. Max Heap (Priority Queue) Method:
12-
* - Maintains a max heap of size k, inserting numbers and removing the
13-
* largest when the heap exceeds size k.
14-
* - Time Complexity: O(n log k)
15-
*
16-
* 3. nth_element Method:
17-
* - Uses std::nth_element to partition the vector so that the first k
18-
* elements are the smallest, then sorts those k numbers.
19-
* - Average Time Complexity: O(n)
20-
*
216
* Edge Cases:
227
* - If k is 0, an empty vector is returned.
238
* - If k is greater than or equal to the input size, the entire sorted list is

0 commit comments

Comments
 (0)