Dynamic Programming21 sections · 916 units
Open in Course

LeetCode 808 Soup Servings - Walkthrough

Understanding the approximation

Serve soup from two pots A and B. Each operation reduces (A, B) by one of 4 choices. Find probability A empties first (or tie counts as 0.5).

For small NN, use DP: dp[a][b]dp[a][b] = probability A empties first from state (a,b)(a, b). observation: on average, A decreases faster than B (operations favor reducing A). For large NN, probability approaches 1. improvement: for N>4800N > 4800, return 1.0 directly. The error is negligible. This bounds the DP state space.