From a6047f86ee79835fc0744d2948805343c5404a04 Mon Sep 17 00:00:00 2001
From: Antim Pal <134076504+iamAntimPal@users.noreply.github.com>
Date: Mon, 14 Apr 2025 20:38:03 +0530
Subject: [PATCH 1/3] Create 875. Koko Eating Bananas.py
Co-Authored-By: Antim-IWP <203163676+Antim-IWP@users.noreply.github.com>
Co-Authored-By: Shiwangi Srivastava <174641070+IamShiwangi@users.noreply.github.com>
---
.../875. Koko Eating Bananas/875. Koko Eating Bananas.py | 6 ++++++
1 file changed, 6 insertions(+)
create mode 100644 Solution/875. Koko Eating Bananas/875. Koko Eating Bananas.py
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
From aa259a79edc5537672a02f9fd7f18d59d616c35f Mon Sep 17 00:00:00 2001
From: Antim Pal <134076504+iamAntimPal@users.noreply.github.com>
Date: Mon, 14 Apr 2025 20:42:56 +0530
Subject: [PATCH 2/3] Create readme.md
Co-Authored-By: Antim-IWP <203163676+Antim-IWP@users.noreply.github.com>
Co-Authored-By: Shiwangi Srivastava <174641070+IamShiwangi@users.noreply.github.com>
---
Solution/875. Koko Eating Bananas/readme.md | 113 ++++++++++++++++++++
1 file changed, 113 insertions(+)
create mode 100644 Solution/875. Koko Eating Bananas/readme.md
diff --git a/Solution/875. Koko Eating Bananas/readme.md b/Solution/875. Koko Eating Bananas/readme.md
new file mode 100644
index 0000000..1b13110
--- /dev/null
+++ b/Solution/875. Koko Eating Bananas/readme.md
@@ -0,0 +1,113 @@
+Sure! Here's a markdown-formatted LeetCode-style explanation for a problem like the one you shared:
+
+---
+
+```markdown
+---
+comments: true
+difficulty: Medium
+edit_url: https://github.com/doocs/leetcode/edit/main/solution/0000-0099/0033.Search%20in%20Rotated%20Sorted%20Array/README_EN.md
+tags:
+ - Array
+ - Binary Search
+---
+
+
+
+# [33. Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array)
+
+[中文文档](/solution/0000-0099/0033.Search%20in%20Rotated%20Sorted%20Array/README.md)
+
+## 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.
+
+
+
+## Solutions
+
+
+
+### Solution 1: Binary Search
+
+Since the array is rotated, we can't directly apply the standard binary search. But we can still use binary search with some modifications by identifying which half of the array is properly sorted.
+
+At each step:
+
+- Check if the left half is sorted.
+- If it is, check whether the target is within the left half.
+- If not, search the right half.
+- Repeat similarly if the right half is sorted.
+
+This approach ensures that with each iteration, we eliminate half the array, maintaining the logarithmic complexity.
+
+Time Complexity: $O(\log n)$
+Space Complexity: $O(1)$
+
+
+
+#### Python3
+
+```python
+class Solution:
+ def search(self, nums: List[int], target: int) -> int:
+ left, right = 0, len(nums) - 1
+ while left <= right:
+ mid = (left + right) // 2
+ if nums[mid] == target:
+ return mid
+ if nums[left] <= nums[mid]:
+ if nums[left] <= target < nums[mid]:
+ right = mid - 1
+ else:
+ left = mid + 1
+ else:
+ if nums[mid] < target <= nums[right]:
+ left = mid + 1
+ else:
+ right = mid - 1
+ return -1
+```
+
+#### Java
+
+```java
+class Solution {
+ public int search(int[] nums, int target) {
+ int l = 0, r = nums.length - 1;
+ while (l <= r) {
+ int mid = (l + r) / 2;
+ if (nums[mid] == target) return mid;
+ if (nums[l] <= nums[mid]) {
+ if (nums[l] <= target && target < nums[mid]) {
+ r = mid - 1;
+ } else {
+ l = mid + 1;
+ }
+ } else {
+ if (nums[mid] < target && target <= nums[r]) {
+ l = mid + 1;
+ } else {
+ r = mid - 1;
+ }
+ }
+ }
+ return -1;
+ }
+}
+```
+
+
+
+
+
+
+```
+
+Let me know which LeetCode problem you'd like next in this format!
\ No newline at end of file
From 16b64f4643f180760c05f8284a401aa6d715cd30 Mon Sep 17 00:00:00 2001
From: Antim Pal <134076504+iamAntimPal@users.noreply.github.com>
Date: Mon, 14 Apr 2025 20:46:12 +0530
Subject: [PATCH 3/3] Update readme.md
Co-Authored-By: Antim-IWP <203163676+Antim-IWP@users.noreply.github.com>
Co-Authored-By: Shiwangi Srivastava <174641070+IamShiwangi@users.noreply.github.com>
---
Solution/875. Koko Eating Bananas/readme.md | 22 +++++++--------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/Solution/875. Koko Eating Bananas/readme.md b/Solution/875. Koko Eating Bananas/readme.md
index 1b13110..013dbeb 100644
--- a/Solution/875. Koko Eating Bananas/readme.md
+++ b/Solution/875. Koko Eating Bananas/readme.md
@@ -1,23 +1,17 @@
-Sure! Here's a markdown-formatted LeetCode-style explanation for a problem like the one you shared:
----
+
+
+# [33. Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array)
+
-```markdown
---
-comments: true
-difficulty: Medium
-edit_url: https://github.com/doocs/leetcode/edit/main/solution/0000-0099/0033.Search%20in%20Rotated%20Sorted%20Array/README_EN.md
-tags:
+- **comments**: true
+- **difficulty**: Medium
+- **tags**:
- Array
- Binary Search
---
-
-
-# [33. Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array)
-
-[中文文档](/solution/0000-0099/0033.Search%20in%20Rotated%20Sorted%20Array/README.md)
-
## Description
@@ -109,5 +103,3 @@ class Solution {
```
-
-Let me know which LeetCode problem you'd like next in this format!
\ No newline at end of file