✅C++ || Recursion->Memoization
\nclass Solution {\npublic:\nunordered_map<long long,vector<pair<long long,long long>>>mp;\nvector<long long>dp;\nlong long maxTaxiEarnings(int n, vector<vector
```\nclass Solution {\npublic:\nunordered_map<long long,vector<pair<long long,long long>>>mp;\nvector<long long>dp;\nlong long maxTaxiEarnings(int n, vector<vector<int>>& arr) \n{\n\t long long currpos=1;\n\t dp.resize(n+1,-1);\n\t for(int i=0;i<arr.size();i++)\n\t {\n\t \tvector<int>temp=arr[i];\n\t \tlong long int start=temp[0];\n\t \tlong long int end=temp[1];\n\t \tlong long int tip=temp[2];\n\t \t\n\t \tmp[start].push_back(make_pair(end,tip));\n     }   \n     return fun(currpos,n);\n}\nlong long fun(long long currpos,int &n)\n{\n\t//base case\n\tif(currpos==n)\n\t{\n\t\treturn 0;\n\t}\n\tif(dp[currpos]!=-1)\n\t{\n\t\treturn dp[currpos];\n\t}\n\tif(mp[currpos].size()>0)   //we have passengers on this point\n\t{\n\t\tlong long choise1=INT_MIN;\n\t\tfor(int i=0;i<mp[currpos].size();i++)\n\t\t{\n\t\t\t//basically we dont have option for the passengers need to carry all of them atleast one time\n\t\t\t//take choise we will consider here\n\t\t    auto p = mp[currpos][i];\n\t\t    \n\t\t    long long start=currpos;\n\t\t    long long end=p.first;\n\t\t    long long tip=p.second;\n\t\t    \n            long long temp = (end-start+tip) + fun(end,n) + 0LL;\n            \n            choise1=max(choise1,temp);\n\t\t}\n\t    long long choise2 =  0 + fun(currpos+1,n);\n\t    return dp[currpos]=  max(choise1,choise2);\n\t}\n\telse if(mp[currpos].size()==0)  //we dont have passengers on the currpos \n\t{\n\t   \treturn dp[currpos] =  0 + fun(currpos+1,n);\n\t}\n\treturn 0;    //this will never get encounterd\n}\n};\n```
['Dynamic Programming', 'Memoization', 'C', 'C++']