DP - recursive algo to solve the problem