Probability and Expected Value Dynamic Programming: Markov Chains & Absorbing States

Expected value recurrences typically operate backward from terminal absorbing states toward the starting state. Let $E[u]$ denote the expected number of steps to reach the target from state $u$:

E[u] = 1 + \sum_{v} P(u \to v) \cdot E[v]

Ready to Master LeetCode Hard Patterns?

Get instant lifetime access to all 45 video lectures, interactive source code templates, and interview prep guides.

Enroll in Masterclass ($49)

Disclaimer: LeetCode is a registered trademark of LeetCode LLC. Our tutorials are independent educational guides developed by industry veterans and are not affiliated with LeetCode.