dp, be careful about edge case
add comment for iterative way