python brute force
\nclass Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:\n        d = {\'U\':(-1, 0),\'D\':(1, 0), \'R\':(0, 1), 
```\nclass Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:\n        d = {\'U\':(-1, 0),\'D\':(1, 0), \'R\':(0, 1), \'L\':(0, -1)}\n        m = len(s)\n        ans = [0]*m\n        \n        def isBounded(start, end):\n            return (0<= start < n and 0<= end < n)\n                \n        for i in range(m):\n            x, y = startPos\n            for j in range(i, m):\n                dx, dy = d[s[j]]\n                x += dx; y += dy\n                \n                if not isBounded(x, y):\n                    break\n                ans[i] += 1\n        return ans\n```
['Python', 'Python3']