dynamic programming use array