Python easy to understand
\nclass Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:\n        res = []\n        rows = cols = n\n        \n  
```\nclass Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:\n        res = []\n        rows = cols = n\n        \n        for i in range(len(s)):\n            steps = 0; row, col = startPos; j = i\n            \n            while j < len(s):\n                if s[j] == \'L\':\n                    col -= 1\n                elif s[j] == \'R\':\n                    col += 1\n                elif s[j] == \'U\':\n                    row -= 1\n                else:\n                    row += 1\n                    \n                j += 1\n                if 0 <= row < rows and 0 <= col < cols:\n                    steps += 1\n                else:\n                    break\n                \n            res.append(steps)\n        return res\n```
[]