Simple Brute Force Solution || C++ Clean Code
Idea :\n\n Approach is pretty straightforward. Starting from each index of string, we need to check till how much steps we can move.\n If we cannot move further
**Idea :**\n\n* Approach is pretty straightforward. Starting from each index of string, we need to check till how much steps we can move.\n* If we cannot move further then stop checking further and break out. And start with next index.\n# Code :\n\n```\nstatic int X[4] = {0,0,-1,1};\nstatic int Y[4] = {1,-1,0,0};\nstatic unordered_map<char, int> mp = {\n    {\'R\', 0},\n    {\'L\', 1},\n    {\'U\', 2},\n    {\'D\', 3}\n};\n\nclass Solution {\npublic:\n    vector<int> executeInstructions(int n, vector<int>& startPos, string s) {\n        \n        int m = s.size();\n        vector<int> res(m);\n\t\t\n        for(int i=0; i<m; i++) {\n            int j=i, cnt = 0;\n            int x = startPos[0], y = startPos[1];\n            while(j<m) {\n                x += X[mp[s[j]]];\n                y += Y[mp[s[j]]];\n                \n                if(x >= 0 && x < n && y >= 0 && y < n) {\n\t\t\t\t\tcnt++, j++;\n\t\t\t\t}\n                else break;\n            }\n            res[i] = cnt;\n        }\n        return res;\n    }\n};\n```\n\n**Complexity :**\n\n* Time : `O(m*m)`, m is size of string `s`\n* Space : `O(1)`
['C']