C++ || Simple solution
\nclass Solution {\npublic:\n\tint getHorizontalPosition(int dx, char c) {\n\t\tif(c == \'R\')\treturn dx + 1 ;\n\t\tif(c == \'L\')\treturn dx - 1 ;\n\t\telse\t
```\nclass Solution {\npublic:\n\tint getHorizontalPosition(int dx, char c) {\n\t\tif(c == \'R\')\treturn dx + 1 ;\n\t\tif(c == \'L\')\treturn dx - 1 ;\n\t\telse\t\t\treturn dx ;\n\t}\n\t\n\tint getVerticalPosition(int dy, char c) {\n\t\tif(c == \'D\')\treturn dy + 1 ;\n\t\tif(c == \'U\')\treturn dy - 1 ;\n\t\telse\t\t\treturn dy ;\n\t}\n    \n    bool isOutside(int currentRow, int currentCol, int n) {\n    \treturn (currentCol == n || currentCol == -1 || currentRow == n || currentRow == -1) ;\n\t}\n    vector<int> executeInstructions(int n, vector<int>& startPos, string s) {\n        vector<int> res ;\n        \n        int step = 0 ;\n        int currentRow = startPos[0] ;\n        int currentCol = startPos[1] ;\n    \n        for(int i = 0 ; i < s.size() ; i++) {\n            currentCol = getHorizontalPosition(currentCol, s.at(i)) ;\n            currentRow = getVerticalPosition  (currentRow, s.at(i)) ;\n            \n            for(int j = i + 1 ; j < s.size() ; j++) {\n                if(isOutside(currentRow, currentCol, n) || step == s.size() - i - 1) {\n                \tbreak ;\n                }\n                \n                step++ ; \n            \tcurrentCol = getHorizontalPosition(currentCol, s.at(j)) ;\n            \tcurrentRow = getVerticalPosition  (currentRow, s.at(j)) ;\n\n            }\n            \n            if(isOutside(currentRow, currentCol, n) || step == s.size() - i - 1) {\n                if(step + 1 == s.size() - i && !isOutside(currentRow, currentCol, n))    \n                    res.push_back(step + 1) ;\n                \n                else if(isOutside(currentRow, currentCol, n))    \n                    res.push_back(step) ;\n            }          \n            \n            step = 0 ;\n            currentRow = startPos[0] ;\n            currentCol = startPos[1] ;\n        }\n        \n        return res ;\n    }\n};\n```
['C']