Python DFS | Easy Read
\n     class Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:\n        dir_check = {\n            \'R\': [0, 1],\
\n     class Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:\n        dir_check = {\n            \'R\': [0, 1],\n            \'L\': [0, -1],\n            \'U\': [-1,0],\n            \'D\': [1,0]\n        }\n        \n        def dfs(curr_x, curr_y, res, i):\n            if i < len(s):\n                dir_x, dir_y = dir_check[s[i]]\n\t\t\t\t\n                new_dir_x = dir_x + curr_x\n                new_dir_y = dir_y + curr_y\n\n                if new_dir_x >= 0 and new_dir_x < n and new_dir_y >= 0 and new_dir_y < n:\n                    res += 1\n                    res = dfs(new_dir_x, new_dir_y, res, i + 1)    \n            return res \n\t\t\t\n        ans = []\n        for i in range(len(s)):\n            ans.append(dfs(startPos[0], startPos[1], 0, i))\n        return ans
['Depth-First Search', 'Python']