same dp, another writting format, but solution1 is much better