Python Solution
\nclass Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:\n        result = []\n        for idx in range(len(s)):\
```\nclass Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:\n        result = []\n        for idx in range(len(s)):\n            count, row, col = 0, startPos[0],startPos[1]\n            while  idx < len(s):\n                if s[idx] == \'D\':\n                    row += 1\n                    if row >= n:\n                        break\n                    count += 1\n                elif s[idx] == \'U\':\n                    row -= 1\n                    if row < 0:\n                        break\n                    count += 1\n                elif s[idx] == \'R\':\n                    col += 1\n                    if col >= n:\n                        break\n                    count += 1\n                else:\n                    col -= 1\n                    if col < 0:\n                        break\n                    count += 1\n                idx += 1\n            result.append(count)\n        return result\n```
['Python']