본문 바로가기 메뉴 바로가기

Daniel's blog

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

Daniel's blog

검색하기 폼
  • 분류 전체보기 (366)
    • 경제(Economy) (15)
      • The Economist Espresso (10)
    • 기술(Tech, IT) (333)
      • 깃(Git) (1)
      • 네트워크 (Networking) (19)
      • 데이터베이스(Database) (9)
      • 리트코드(LeetCode) (38)
      • 머신 러닝(Machine Learning) (43)
      • 소프트웨어 품질 (Software Quality .. (2)
      • 안드로이드(Android) (15)
      • 알고리즘(Algorithm) (14)
      • 웹(Web) (4)
      • 인터뷰 (Interview) (3)
      • 임베디드 (Embedded) (42)
      • 자바(Java) (17)
      • 컴퓨터 그래픽스 (Computer Graphics.. (24)
      • 컴퓨터 비전 (Computer Vision) (5)
      • 파이썬(Python) (25)
      • C++ (23)
      • etc. (47)
    • 바이오(Biology) (1)
    • 서평(Book Review) (2)
    • 영어(English) (5)
    • 상식 및 기타(Common Sense and et.. (9)
  • 방명록

max heap (1)
[LeetCode] 1244. Design A Leaderboard

다른 함수들은 모두 간단히 구현이 가능하지만 top을 어떻게 구현하느냐에 따라 효율이 달라진다. list를 heap로 구성하는 heapify를 통해 max heap을 구현후 하나씩 pop하는 방식을 활용해 K개의 가장 높은 점수를 더해 반환했다. import heapq class Leaderboard: def __init__(self): self.dic = defaultdict(int) def addScore(self, playerId: int, score: int) -> None: self.dic[playerId] += score def top(self, K: int) -> int: ret = 0 values = list(self.dic.values()) n_values = [-val for val i..

기술(Tech, IT)/리트코드(LeetCode) 2023. 8. 2. 07:59
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • 오블완
  • 이코노미스트 에스프레소
  • machine learning
  • C++
  • The Economist
  • 딕셔너리
  • DICTIONARY
  • 이코노미스트
  • 리트코드
  • I2C
  • 투 포인터
  • tf-idf
  • Python
  • defaultdict
  • Hash Map
  • 안드로이드
  • 티스토리챌린지
  • java
  • 소켓 프로그래밍
  • leetcode
  • vertex shader
  • Computer Graphics
  • socket programming
  • join
  • 파이썬
  • Android
  • The Economist Espresso
  • ml
  • min heap
  • 머신 러닝
more
«   2025/07   »
일 월 화 수 목 금 토
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함
반응형

Blog is powered by Tistory / Designed by Tistory

티스토리툴바