Very clear & self-explanatory code | C++
\nclass Solution {\npublic:\n    unordered_map<char, pair<int, int>> mp {\n        {\'L\', {0, -1}},\n        {\'R\', {0, 1}},\n        {\'U\', {-1, 0}},\n     
```\nclass Solution {\npublic:\n    unordered_map<char, pair<int, int>> mp {\n        {\'L\', {0, -1}},\n        {\'R\', {0, 1}},\n        {\'U\', {-1, 0}},\n        {\'D\', {1, 0}}\n    };\n    \n    bool isSafe(int n, int r, int c) {\n        return r >= 0 && r < n && c >= 0 && c < n;    \n    }\n    \n    vector<int> executeInstructions(int n, vector<int>& startPos, string &s) {\n        int m = s.length();\n        vector<int> ans(m);\n        for(int i=0; i<m; i++) {\n            int len = 0;\n            int r = startPos[0], c = startPos[1];\n            for(int j=i; j<m; j++) {\n                r = r + mp[s[j]].first, c = c + mp[s[j]].second;\n                if(isSafe(n, r, c))\n                    len++;\n                else\n                    break;\n            }\n            ans[i] = len;\n        }\n        return ans;\n    }\n};\n```
['C', 'Simulation', 'C++']