✅C++ || Straightforward || EASY CODE
\n\nT->O(m^2) && S->O(n)\n\n\tclass Solution {\n\tpublic:\n\t\tvector executeInstructions(int n, vector& start, string s) {\n\t\t\tint m=s.size();\n\t\t\tvector
![image](https://assets.leetcode.com/users/images/a8b2eeac-067b-420c-9885-9bb72fd4b338_1660389613.2288911.png)\n\n**T->O(m^2) && S->O(n)**\n\n\tclass Solution {\n\tpublic:\n\t\tvector<int> executeInstructions(int n, vector<int>& start, string s) {\n\t\t\tint m=s.size();\n\t\t\tvector<int> ans(m);\n\t\t\tfor(int l=0;l<m;l++){\n\t\t\t\tint count=0;\n\t\t\t\tint i=start[0],j=start[1];\n\t\t\t\tfor(int k=l;k<m;k++){\n\t\t\t\t\tif(s[k]==\'L\'){\n\t\t\t\t\t\tif(j-1>=0){\n\t\t\t\t\t\t\tj--;\n\t\t\t\t\t\t\tcount++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse break;\n\t\t\t\t\t}\n\t\t\t\t\telse if(s[k]==\'R\'){\n\t\t\t\t\t\tif(j+1<n){\n\t\t\t\t\t\t\tj++;\n\t\t\t\t\t\t\tcount++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse break;\n\t\t\t\t\t}\n\t\t\t\t\telse if(s[k]==\'U\'){\n\t\t\t\t\t\tif(i-1>=0){\n\t\t\t\t\t\t\ti--;\n\t\t\t\t\t\t\tcount++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse break;\n\t\t\t\t\t} \n\t\t\t\t\telse{\n\t\t\t\t\t\tif(i+1<n){\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\tcount++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse break;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tans[l]=count;\n\t\t\t}\n\t\t\treturn ans;\n\t\t}\n\t};
['C', 'C++']