본문 바로가기
반응형

분류 전체보기128

[DSA][Binary Search] 06. Time Based Key-Value Store LeetCode 981 06. Time Based Key-Value StoreDesign a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at a certain timestamp.Implement the TimeMap class:- TimeMap() Initializes the object of the data structure.- void set(String key, String value, int timestamp) Stores the key key with the value value at the g.. 2025. 6. 21.
[DSA][Binary Search] 05. Search in Rotated Sorted Array LeetCode 33 05. Search in Rotated Sorted ArrayThere is an integer array nums sorted in ascending order (with distinct values).Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1 [질문하기]- 배열에 항상 target 값이 존재하나요? NO [아이디어]- mid 인덱스의 값과 r 인덱스의 값을 비교하여 정렬된 구간을 찾고, 정렬된 구간에 대해 target이 있을 위치를 추적하자. [풀이 1] Binary Searchclass Solution: def search(self, nu.. 2025. 6. 19.
[DSA][Binary Search] 04. Find Minimum in Rotated Sorted Array LeetCode 153 04. Find Minimum in Rotated Sorted ArraySuppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become:- [4,5,6,7,0,1,2] if it was rotated 4 times.- [0,1,2,4,5,6,7] if it was rotated 7 times.Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the array [a[n-1], a[0], a[1].. 2025. 6. 18.
[DSA][Binary Search] 03. Koko Eating Bananas LeetCode 875 03. Koko Eating BananasKoko loves to eat bananas. There are n piles of bananas, the ith pile has piles[i] bananas.The guards have gone and will come back in h hours. Koko can decide her bananas-per-hour eating speed of k.Each hour, she chooses some pile of bananas and eats k bananas from that pile.If the pile has less than k bananas, she eats all of them instead and will not eat any.. 2025. 6. 17.