Open JangoBoogaloo opened 1 month ago
Define the upper/lower bound of the answer, try binary search guess. Have a method to verify if the guess result bigger or smaller than the criteria
guess
criteria
https://leetcode.com/problems/minimum-time-to-repair-cars/ <-- this one is gold!!! https://leetcode.com/problems/minimum-speed-to-arrive-on-time/ https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/ https://leetcode.com/problems/koko-eating-bananas/ https://leetcode.com/problems/maximum-candies-allocated-to-k-children/ https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets/ https://leetcode.com/problems/sell-diminishing-valued-colored-balls/ https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag/ https://leetcode.com/problems/divide-chocolate/ <-- this one is gold!!! (hard)
mid = (left + right) //2 left = mid + 1 right = mid
mid = (left + right) //2
left = mid + 1
right = mid
mid = (left + right+1) //2 right = mid - 1 left = mid
mid = (left + right+1) //2
right = mid - 1
left = mid
❗ Need a better Binary Search formula
Concept
Define the upper/lower bound of the answer, try binary search
guess
. Have a method to verify if theguess
result bigger or smaller than thecriteria
Question Set
https://leetcode.com/problems/minimum-time-to-repair-cars/ <-- this one is gold!!! https://leetcode.com/problems/minimum-speed-to-arrive-on-time/ https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/ https://leetcode.com/problems/koko-eating-bananas/ https://leetcode.com/problems/maximum-candies-allocated-to-k-children/ https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets/ https://leetcode.com/problems/sell-diminishing-valued-colored-balls/ https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag/ https://leetcode.com/problems/divide-chocolate/ <-- this one is gold!!! (hard)