일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 잡생각
- 10분
- 영어원서읽기
- 만화도
- 괜찮음
- 사이드
- 월간
- 개발자
- 화상영어
- Daily Challenge
- 프로젝트
- FIT XR
- 리얼 클래스
- 3줄정리
- 링피트
- 30분
- 매일
- 운동
- Writing
- realclass
- 영어공부
- 읽기
- leetcode
- 스탭퍼
- English
- 뭐든
- 쓰릴오브파이트
- 파비최
- 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