Charles Schwab Interview Question

It was about a DP problem