Open LogicBaron opened 1 year ago
The first problem is 808. Soup Serving. https://leetcode.com/problems/soup-servings/ This problem can be easily thought of using dynamic programming, but it can be confusing because the range of n is very large (10^9).
However, if you look carefully at the conditions of the problem, you can see that since the average consumption of Soup B is less than that of Soup A. Therefore, you can almost always know that Soup A will run out first if the execution is repeated countless times.(Roughly around 5000 times)
This is a part that cannot be thought of if you only focus on DP.
The second problem is 877. Stone Game https://leetcode.com/problems/stone-game/
Given that the number of stones is even and Alice can go first, Alice can always pick up all the stones with even numbers or odd numbers. Since Alice can win with a tie, she just needs to choose the set with more stones, whether it's even or odd. So, Alice can always win.
If the number of stones is odd, the situation is a bit different. In this case, you need to solve it using DP. 486. Predict the Winner https://leetcode.com/problems/predict-the-winner/
365. Water and Jug Problem https://leetcode.com/problems/water-and-jug-problem/description/
What is the minimum amount of water you can make with two jugs?
Let's not just focus on algorithms. Some problems require more than just understanding algorithms.