[Python] Straight-forward O(n ^ 2) solution (still fast - 85%)
Complexity\n- Time complexity:\nO(N ^ 2)\n- Space complexity:\nO(N)\n\n# Code\npython []\nclass Solution:\n    def executeInstructions(self, n: int, startPos: l
# Complexity\n- Time complexity:\nO(N ^ 2)\n- Space complexity:\nO(N)\n\n# Code\n```python []\nclass Solution:\n    def executeInstructions(self, n: int, startPos: list[int], s: str) -> list[int]:\n\n        def num_of_valid_instructions(s, pos, start, end):\n            row, colon = pos\n            k = 0\n            for i in range(start, end):\n                cur = s[i]\n                row += (cur == \'D\') - (cur == \'U\')\n                colon += (cur == \'R\') - (cur == \'L\')\n                if not (0 <= row < n and 0 <= colon < n):\n                    return k\n                k += 1\n            return k\n\n        ans = []\n        for i in range(len(s)):\n            ans.append(num_of_valid_instructions(s, startPos, i, len(s)))\n        return ans\n```
['String', 'Simulation', 'Python3']