gary@interview:~/interview/coding/1306-jump-game-iii.md$
$ cat ./coding/1306-jump-game-iii.md
[Coding]

1306. Jump Game III

────────────────────────────────────────────────────────────

1306. Jump Game III

class Solution:
    def canReach(self, arr: List[int], start: int) -> bool:
        
        q = deque([start])
        visited = set()
        visited.add(start)
        
        directions = [1, -1]
        
        while q:
            size = len(q)
            node = q.popleft()
            if arr[node] == 0:
                return True
            for d in directions:
                nextPos = node + arr[node]*d
                if 0 <= nextPos < len(arr) and nextPos not in visited:
                    q.append(nextPos)
                    visited.add(nextPos)
        
        return False
--tags#Tree
$ ls ./coding/ | grep -v 1306-jump-game-iii
265. Paint House II256. Paint House143. Reorder List1762. Buildings With an Ocean View
← cd ../codingcd ~