You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This discussion was converted from issue #134 on September 15, 2026 11:11.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Problem link
https://leetcode.com/problems/kth-largest-element-in-a-stream/
Problem Summary
stream이 주어질 때 순서대로 k번째로 큰 수를 출력하는 문제
Solution
min heap으로 간단히 구현할 수 있다.
처음에는 heap 2개를 썼는데 k개만 관리하면 돼서 k 길이의 min heap 하나면 충분하다.
k 길이의 min heap을 관리하면서 min heap에서 가장 작은 값보다 큰 값이 들어오면 min heap에서 빼고 갱신해주면 된다.
Source Code
All reactions