diff --git a/Solution/875. Koko Eating Bananas/875. Koko Eating Bananas.py b/Solution/875. Koko Eating Bananas/875. Koko Eating Bananas.py new file mode 100644 index 0000000..ffa7923 --- /dev/null +++ b/Solution/875. Koko Eating Bananas/875. Koko Eating Bananas.py @@ -0,0 +1,6 @@ +class Solution: + def minEatingSpeed(self, piles: List[int], h: int) -> int: + def check(k: int) -> bool: + return sum((x + k - 1) // k for x in piles) <= h + + return 1 + bisect_left(range(1, max(piles) + 1), True, key=check) \ No newline at end of file diff --git a/Solution/875. Koko Eating Bananas/readme.md b/Solution/875. Koko Eating Bananas/readme.md new file mode 100644 index 0000000..013dbeb --- /dev/null +++ b/Solution/875. Koko Eating Bananas/readme.md @@ -0,0 +1,105 @@ + + + +# [33. Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array) + + +--- +- **comments**: true +- **difficulty**: Medium +- **tags**: + - Array + - Binary Search +--- + +## Description + + + +
There is an integer array nums sorted in ascending order (with distinct values), which is rotated at an unknown pivot index k (0 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]] (0-indexed). For example, [0,1,2,4,5,6,7] might be rotated at pivot index 3 and become [4,5,6,7,0,1,2].
Given the array nums after the rotation and an integer target, return the index of target if it is in nums, or -1 if it is not in nums.
You must write an algorithm with O(log n) runtime complexity.