good one, use recursive and dynamic programming