fixing the comments

This commit is contained in:
Jidong Xiao
2025-04-22 19:36:01 -04:00
committed by JamesFlare1212
parent 83e54834d8
commit 2fa18a094f

View File

@@ -142,8 +142,8 @@ void heapify(std::vector<int>& nums, int n, int i){
smallest = right;
}
// after the above, smallest basically will either stay the same, or will be either left or right, depending on nums[left] is larger or nums[right] is larger. largest stays the same if it is already larger than its two children.
// if largest is changed, then we do need to swap.
// after the above, smallest basically will either stay the same, or will be either left or right, depending on nums[left] is smaller or nums[right] is smaller. smallest stays the same if it is already smallest than its two children.
// if smallest is changed, then we do need to swap.
if(smallest != i){
std::swap(nums[i], nums[smallest]);
heapify(nums, n, smallest);