본문 바로가기
반응형

분류 전체보기63

[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.
[DSA][Binary Search] 02. Search a 2D Matrix LeetCode 74 02. Search a 2D MatrixYou are given an m x n integer matrix matrix with the following two properties:- Each row is sorted in non-decreasing order.- The first integer of each row is greater than the last integer of the previous row.Given an integer target, return true if target is in matrix or false otherwise.You must write a solution in O(log(m * n)) time complexity. [질문하기]- 행렬의 크기 .. 2025. 6. 16.