Intuition
- Same as House Robber, just aware when pick the last number, the first one cannot be selected, so the range is 1 to n - 2
solution
|
|
problem
WA.
reason
Maybe not that simple, there’s a probability that the first one has not be selected when calculate the dp[0][n - 2]
modification
It’s equals to the problem that Math.max(steal from 0 to n - 2, steal from 1 to n - 1)
|
|