#include<map>
using namespace std;
class Solution {
public:
int fib(int n) {
if(n==0) return 0;
if(n==1) return 1;
if(temp.find(n)!=temp.end()){
return (temp.find(n)->second)%(1000000007);
}else{
int sum = fib(n-1)+fib(n-2);
temp.insert(pair<int,int>(n,sum));
return (sum%(1000000007));
}
}
private:
map<int,int>temp;
};
同爬楼梯问题