Practice/Google/Leetcode 1553. Minimum Number of Days to Eat N Oranges
CodingMust
You have n pieces of fruit in your basket. Each day, you must eat some fruit according to the following rules:
Your goal is to eat all the fruit (reduce the count to zero) in the minimum number of days.
Return the minimum number of days needed to eat all n pieces of fruit.
Example 1:
Input: n = 10 Output: 4 Explanation: Day 1: Eat 1 fruit (9 remaining) Day 2: 9 is divisible by 3, eat 6 fruit leaving 3 Day 3: 3 is divisible by 3, eat 2 fruit leaving 1 Day 4: Eat 1 fruit (0 remaining) Total: 4 days
Example 2:
Input: n = 6 Output: 3 Explanation: Day 1: 6 is divisible by 2, eat 3 fruit leaving 3 Day 2: 3 is divisible by 3, eat 2 fruit leaving 1 Day 3: Eat 1 fruit (0 remaining) Total: 3 days
Example 3:
Input: n = 1 Output: 1 Explanation: Day 1: Eat 1 fruit (0 remaining) Total: 1 day
Example 4:
Input: n = 82 Output: 7 Explanation: One optimal path: 82 → 81 (eat 1) → 27 (÷3) → 26 (eat 1) → 13 (÷2) → 12 (eat 1) → 4 (÷3) → 2 (÷2) → 0 This takes 7 days total.