C++ | with comments |  easy to understand
Just do whatever is asked.\nFollow the instructions starting from the 0th index.\nTime Complexity:-O(m^2)\n\n\nclass Solution {\npublic:\n    vector<int> execut
Just do whatever is asked.\nFollow the instructions starting from the 0th index.\n**Time Complexity:**-O(m^2)\n\n```\nclass Solution {\npublic:\n    vector<int> executeInstructions(int n, vector<int>& start, string s) {\n        int size=s.size();\n        vector<int>ans(size,0);\n\t\t// for finding answer iterate over all points one by one\n        for(int i=0;i<size;i++)\n           ans[i]= findSteps(n,s,start[0],start[1],i);\n        return ans; \n    }\n\t// check how many steps you can go\n    int findSteps(int &n,string &s,int row,int col,int pos){\n       int ans=0;\n        for(int i=pos;i<s.size();i++){\n            if(s[i]==\'L\')\n                col--;\n            else if(s[i]==\'R\')\n                col++;\n            else if(s[i]==\'U\')\n                row--;\n            else\n                row++;\n\t\t\t\t// if it is true then this move is invalid,return ans\n            if(row<0 || col<0 || row>=n || col>=n)\n                return ans;\n\t\t\t\t// else go to next move.\n            ans++;\n        }\n        return ans;\n    }\n};\n```\nDo **UPVOTE** if it helps :)
['C']