dynamic programming tips