일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- realclass
- 사이드
- 10분
- FIT XR
- 잡생각
- English
- Writing
- 영어공부
- 매일
- 개발자
- 스탭퍼
- 뭐든
- 링피트
- 만화도
- 운동
- 30분
- 미드시청
- Daily Challenge
- leetcode
- 쓰릴오브파이트
- 프로젝트
- 3줄정리
- 월간
- 화상영어
- 읽기
- 영어원서읽기
- 파비최
- 괜찮음
- 리얼 클래스
- Problem Solving
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.06.11 Today's Challenge 본문
https://leetcode.com/problems/snapshot-array/
그리 어렵지는 않았던 문제
class SnapshotArray:
def __init__(self, length: int):
self.id = 0
self.history_records = [[[0, 0]] for _ in range(length)]
def set(self, index: int, val: int) -> None:
self.history_records[index].append([self.id, val])
def snap(self) -> int:
self.id += 1
return self.id - 1
def get(self, index: int, snap_id: int) -> int:
snap_index = bisect.bisect_right(self.history_records[index], [snap_id, 10**9])
return self.history_records[index][snap_index-1][1]
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.06.13 Today's Challenge (0) | 2023.06.13 |
---|---|
2023.06.12 Today's Challenge (0) | 2023.06.12 |
2023.06.10 Today's Challenge (0) | 2023.06.10 |
2023.06.09 Today's Challenge (0) | 2023.06.09 |
2023.06.08 Today's Challenge (0) | 2023.06.08 |
Comments