Python3 O(N ^ 2) solution with simulation (92.80% Runtime)
Intuition\n Describe your first thoughts on how to solve this problem. \n\nIteratively check for out of bounds while updating counts\n\n# Approach\n Describe yo
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n![image.png](https://assets.leetcode.com/users/images/cee5ce8d-f90f-434d-b929-81459715328f_1702043613.5384393.png)\nIteratively check for out of bounds while updating counts\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- From start location, iteratively check if the next position is out of bounds\n- For each start index "i", update "i"th possible movements before out of bounds\n\n# Complexity\n- Time complexity: O(N ^ 2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\nIf this solution is similar to yours or helpful, upvote me if you don\'t mind\n```\nclass Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:\n        l = len(s)\n        ans = [0] * l\n\n        for i in range(l):\n            cnt = 0\n            y, x = startPos\n\n            for c in s[i:]:\n                if c == "U":\n                    y -= 1\n                elif c == "D":\n                    y += 1\n                elif c == "R":\n                    x += 1\n                else:\n                    x -= 1\n\n                if x >= n or y >= n or x < 0 or y < 0:\n                    break\n                cnt += 1\n\n            ans[i] = cnt\n        \n        return ans\n```
['Simulation', 'Python', 'Python3']