dfs+HashMap剪枝
import java.util.*;
public class Solution {Map<Integer,Integer>memo=new HashMap<>();
public int jumpFloor(int target) {
if(target==0){
return 0;
}
return dfs(target);
}
int dfs(int target){
if(memo.containsKey(target)){
return memo.get(target);
}
if(target<0){
return 0;
}
else if(target==0){
return 1;
}
int res1=dfs(target-1);
int res2=dfs(target-2);
memo.put(target,res1+res2);
return res1+res2;
}
}