The problem, in one line. Given daily prices, find the best total profit from any number of buy and sell trades, holding at most one share, where the day after a sale you may not buy. LeetCode 309.
The tell. A choice each day whose options depend on what you did yesterday. Days along one axis and “what state am I in” along the other is a 2-D table, even when the code ends up keeping only three numbers.