✅ Execution of ALL Suffix Instruction Staying in a Grid
\nclass Solution {\npublic:\n     pair<int,int> convert(char s,int i,int j)\n    {\n        if(s==\'R\')\n            return {i,j+1};\n        if(s==\'D\')\n   
```\nclass Solution {\npublic:\n     pair<int,int> convert(char s,int i,int j)\n    {\n        if(s==\'R\')\n            return {i,j+1};\n        if(s==\'D\')\n            return {i+1,j};\n        if(s==\'L\')\n            return {i,j-1};\n        if(s==\'U\')\n            return {i-1,j};\n        return {0,0};\n    }\n    \n    int solve(int n,int m, string str , int i,int j)\n    {\n        int count = 0;\n        for(int u=0;u<str.length();u++)\n        {\n            char t = str[u];\n            auto it = convert(t,i,j);\n            i = it.first;\n            j = it.second;\n            if(i<0 || j<0 || i>=n || j>= n)\n                return count;\n            count++;\n        }\n       return count;\n    }\n    vector<int> executeInstructions(int n, vector<int>& startPos, string s) \n    {\n        vector<int>ans;\n        for(int i=0;i<s.length();i++)\n        {\n            string temp = s.substr(i);\n            int k = solve(n,n,temp,startPos[0],startPos[1]);\n            ans.push_back(k);\n        }\n        return ans;\n    }\n};\n```
['C']