Skip to content

July 20, 2025 - Daily Drill

🎯 Daily Goals

  • Review Anki Deck
  • Lumosity training
  • Leetcode
  • Developing pdf-chat

📝 What I learned:

Leetcode problem

Solved again using backtracking and divide and conquer

22. Generate Parentheses

Key Takeaways

  • How to define a valid parenthesis string recursively: "(" + left_valid + ")" + right_valid

875. Koko Eating Bananas

Thinking Process

From the constraint we can see that h is at least equal to the length of piles. Thus, it is always possible for koko to finish in time. Ask for clarification if this is not included in the prompt. We can also infer that the largest minimal speed possible is the max(piles). A native solution would be iterate through 1 to max(piles) and see which one satisfies the requirement. For better runtime, we can do a binary search that set the initial speed at (1 + max(piles)) // 2. In log(n) time we can find the minimum viable speed.

Complexity Analysis

Denote the maximum of the piles as m and the length of piles as n.

Time Complexity: O(nlog(m)) Space Complexity: O(1)