211. Design Add and Search Words Data Structure

새 단어 추가를 지원하고 문자열이 이전에 추가된 문자열과 일치하는지 확인하는 데이터 구조를 설계

  • void addWord(word) 데이터 구조에 단어를 추가하고 나중에 일치시킬 수 있습니다.
  • bool search(word) 데이터 구조에 단어와 일치하는 문자열이 있으면 true를 반환하고 그렇지 않으면 false를 반환

Continue reading

901. Online Stock Span

일부 주식에 대한 일일 가격 시세를 수집하고 현재 날짜의 해당 주식 가격 범위를 반환하는 알고리즘을 설계합니다.

  • 하루 동안의 주가 범위는 주가가 그날의 가격보다 작거나 같은 최대 연속 일수(당일부터 시작하여 뒤로)입니다.
  • Example: [100,80,60,70,60,75,86] -> [1,1,1,2,1,4,6]

Continue reading

1244. Design A Leaderboard

3가지 기능이 있는 Leaderboard 클래스를 설계

  • addScore(playerId, score): 주어진 플레이어의 점수에 점수를 추가하여 순위표를 업데이트
  • top(K): 상위 K 플레이어의 점수 합계를 반환
  • reset(playerId): 주어진 ID를 가진 플레이어의 점수를 0으로 재설정(즉, 리더보드에서 삭제)

Continue reading

146. LRU Cache

LRU(최소 사용) 캐시의 제약 조건을 따르는 데이터 구조를 설계

  • int get(int key) Return the value of the key if the key exists, otherwise return -1.
  • void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key.
  • The functions get and put must each run in O(1) average time complexity.

Continue reading

Pagination


© 2017. by yeopoong.github.io

Powered by yeopoong