BruteForce
\nclass Solution {\npublic:\n    \n    bool check(int xx,int yy, int n)\n    {\n        if(xx>=0 && yy>=0 && xx<n && yy <n)\n            return true;\n        r
```\nclass Solution {\npublic:\n    \n    bool check(int xx,int yy, int n)\n    {\n        if(xx>=0 && yy>=0 && xx<n && yy <n)\n            return true;\n        return false;\n    }\n    vector<int> executeInstructions(int n, vector<int>& startPos, string s) {\n        \n        unordered_map<char,pair<int,int>> mp{\n            { \'U\',{-1,0}},\n            {\'D\',{1,0}},\n            {\'R\', {0,1}},\n            {\'L\',{0,-1}}\n        };\n        \n        int m = s.size();\n        vector<int> res(m);\n        for(int i=0;i<m;i++)\n        {\n            int len = 0;\n            int x =  startPos[0];\n            int y =  startPos[1];\n            \n            for(int j=i;j<m;j++){\n                x+=mp[s[j]].first;\n                y+=mp[s[j]].second;\n                if(check(x,y,n))\n                    len++;\n                else\n                    break;\n            }\n            res[i] = len;\n            \n        }\n        \n     return res;   \n    }\n};\n```
['C']