DP C++
\n\n# Code\n\nclass Solution {\npublic:\n    int help(int i,string moves,int m,vector<vector<int>>&dp){\n        if(i>=moves.size()) return m;\n      if(dp[i][m
\n\n# Code\n```\nclass Solution {\npublic:\n    int help(int i,string moves,int m,vector<vector<int>>&dp){\n        if(i>=moves.size()) return m;\n      if(dp[i][m+50]!=-1) return dp[i][m+50];\n       // cout<<i<<" "<<m<<endl;\n       int n1=INT_MIN,n2=INT_MIN,n3=INT_MIN;\n    if(moves[i]==\'L\'){\n        \n        n1= abs(help(i+1,moves,m-1,dp));\n    }   \n        else if(moves[i]==\'R\'){\n             n2= abs(help(i+1,moves,m+1,dp));\n        }\n        else{\n            n3 =max(abs(help(i+1,moves,m-1,dp)),abs(help(i+1,moves,m+1,dp)));\n        }\n        return dp[i][m+50]=max(n1,max(n2,n3));\n    }\n    int furthestDistanceFromOrigin(string moves) {\n        vector<vector<int>>dp(moves.size(),vector<int>(moves.size()+51,-1));\n        return help(0,moves,0,dp);\n    }\n};\n```
['Dynamic Programming', 'C++']