added color
Non Recursive version of dynamic programming