
✅ 오늘의 학습 키워드[leetcode] Kth Largest Element in a Stream ✅ Kth Largest Element in a Stream- 문제 - 1차 풀이from typing import Listimport heapqclass KthLargest: def __init__(self, k: int, nums: List[int]): self.k = k self.nums = nums heapq.heapify(self.nums) # 리스트를 최소 힙으로 변환합니다. self.nums = heapq.nlargest(self.k, self.nums) # 가장 큰 k개의 요소만 남기고, 내림차순으로 정렬합니다. def add(self..

✅ 오늘의 학습 키워드[leetcode] Relative Ranksheapq ✅ Relative Ranks- 문제 - 풀이from typing import Listclass Solution: def findRelativeRanks(self, score: List[int]) -> List[str]: ranking = [(s, index) for index, s in enumerate(score)] sorted_ranking = sorted(ranking, key=lambda x: x[0], reverse=True) result = [""] * len(score) def converted_medal(rank, index): meda..