Use Hashmap(DP) to cache results
First use recursive methods, then use Hashmap to implement DP which cache results