시나위

  • 홈
  • 태그
  • 방명록

Leetcode 2

[Leetcode] 2353 Design a Food Rating System, C++

문제 요약 Food Rating System을 만들면 됨 접근 1. 구현 초기화 모든 값을 저장함 -> 새로운 값이 들어올때마다 추가함. cuisines[i]에 어떤 값이 들어있는지 모르므로 새로운 값이 들어올때마다 저장해야함.(unordered_map) cuisines[i] 마다 foods[i]와 ratings[i] 를 우선순위를 주어 저장해야함. (priority_queue) -> 점수가 같으면 사전순으로 작은 이름이 우선임 changeRating 새로운 값으로 바꿈 priority_queue를 사용하므로 값을 제거하기 어려우므로 추가만하는 방향으로 진행 highestRated priority_queue를 사용하면 제일 위에 있는 값을 출력하면 됨. changeRating에서 값을 제거하지 않고 추가..

STUDY/Algorithm 2022.10.13

[LeetCode] 235. Lowest Common Ancestor of a Binary Search Tree, C++

https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/submissions/ Lowest Common Ancestor of a Binary Search Tree - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 이진 탐색 트리에서 가장 가까운 공통 조상을 찾는 문제이다. 알고리즘 순서는 다음과 같다. 1. 주어진 root를 시작으로 BFS를 진행한다. 1-1. 이 때 unorde..

STUDY/Algorithm 2022.08.13
이전
1
다음
더보기
프로필사진

하고 싶은 거 다하고 정리하는 블로그

  • 분류 전체보기 (669)
    • STUDY (529)
      • Algorithm (402)
      • C, C++ (7)
      • Python (33)
      • Rust (28)
      • Swift & iOS (16)
      • Web (10)
      • Raspberry Pi (10)
      • Others (23)
    • OTHERS (140)
      • 내 생각 (134)
      • 리뷰 (5)

Tag

C++, baekjoon, 다익스트라, dp, python, 혼공파, 구현, dfs, BOJ, 백준, C, 파이썬, 프로그래머스, python3, 시뮬레이션, 혼공단, 브루트포스, 그래프탐색, BFS, 백트래킹,

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

공지사항

페이스북 트위터 플러그인

  • Facebook
  • Twitter

Archives

Calendar

«   2025/05   »
일 월 화 수 목 금 토
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

방문자수Total

  • Today :
  • Yesterday :

Copyright © Kakao Corp. All rights reserved.

티스토리툴바