simple c++ solution
\nclass Solution {\npublic:\n   \n   vector<int> executeInstructions(int n, vector<int> &st, string s)\n{\n    vector<int> res;\n    int i1 = st[0], j1 = st[1];
```\nclass Solution {\npublic:\n   \n   vector<int> executeInstructions(int n, vector<int> &st, string s)\n{\n    vector<int> res;\n    int i1 = st[0], j1 = st[1];\n    int a=i1,b=j1;\n    ///  cout<<i1<<" "<<j1<<endl;\n    for (int j = 0; j < s.size(); j++)\n    {\n        int c = 0;\n        for (int i = j; i < s.size(); i++)\n        {\n            if (s[i] == \'U\')\n            {\n                if (i1 - 1 >= 0)\n                   i1--, c++;\n                 else\n                    break;\n            }\n            else if (s[i] == \'R\')\n            {\n                if (j1 + 1 < n)\n                    j1++,c++;\n                else\n                    break;\n            }\n            else if (s[i] == \'D\')\n            {\n                if (i1 + 1 <n)\n                  i1++, c++;\n                 else\n                    break;\n            }\n            else if (s[i] == \'L\')\n            {\n                if (j1 - 1 >= 0)\n                   j1--, c++;\n                 else\n                    break;\n            }\n            else\n                break;\n        }\n        res.push_back(c);\n        i1=a,j1=b;\n    }\n    return res;\n}\n};\n```
[]