[C++] Easy Solution
Time Complexity : O(n^2)\n\nvector<int> executeInstructions(int n, vector<int>& startPos, string s) {\n        int t1,t2,c=0;\n        vector<int> res(s.size())
Time Complexity : O(n^2)\n```\nvector<int> executeInstructions(int n, vector<int>& startPos, string s) {\n        int t1,t2,c=0;\n        vector<int> res(s.size());\n        for(int i=0;i<s.size();i++)\n        {\n            t1=startPos[0];\n            t2=startPos[1];\n            c=0;\n            for(int j=i;j<s.size();j++)\n\t\t\t{\n\t\t\t    if(s[j]==\'L\')\n                {  \n                      t2--;\n                      if(t1>=0 && t1<=n-1 && t2>=0 && t2<=n-1)\n                            c++;\n                      else\n                            break;\n                 }\n            \n                 else if(s[j]==\'R\')\n                 {\n                      t2++;\n                      if(t1>=0 && t1<=n-1 && t2>=0 && t2<=n-1)\n                          c++;\n                      else\n                          break;\n                 }\n                else if(s[j]==\'U\')\n                {\n                      t1--;\n                      if(t1>=0 && t1<=n-1 && t2>=0 && t2<=n-1)\n                           c++;\n                      else\n                           break;\n                }\n                else if(s[j]==\'D\')\n                {\n                     t1++;\n                     if(t1>=0 && t1<=n-1 && t2>=0 && t2<=n-1)\n                          c++;\n                     else\n                         break;\n                }\n            }\n            res[i]=c;\n        }\n        return res;\n    }\n```
['C']