use stack also troublesome.
I think for this question , we should use dp.