Heaps Interview Q - Largest K Elements II


Can we use this code instead of what is done in video? I can modify it so that it works like in the video but is this logic good and time saving?