a new dp solution, rolling array