C++ Easy To Understand [Faster than 85%]
\nclass Solution {\npublic:\n    vector<int> executeInstructions(int n, vector<int>& startPos, string s) {\n        int l=s.length();\n        int x, y;\n      
```\nclass Solution {\npublic:\n    vector<int> executeInstructions(int n, vector<int>& startPos, string s) {\n        int l=s.length();\n        int x, y;\n        int counter;\n        vector<int> ans;\n        for(int i=0;i<l;i++)\n        {\n            counter=0;\n            x=startPos[1];\n            y=startPos[0];\n            for(int j=i;j<l;j++)\n            {\n                if(s[j]==\'R\')\n                    x++;\n                if(s[j]==\'L\')\n                    x--;\n                if(s[j]==\'U\')\n                    y--;\n                if(s[j]==\'D\')\n                    y++;\n                if(x<0 || y<0 || x>=n || y>=n)\n                    break;\n                else\n                    counter++;\n            }\n            ans.push_back(counter);\n        }\n        return ans;\n    }\n};\n```
['C++']