Python BFS solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nUsing vertex hash, go through each vertex to count how long it takes to g
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nUsing vertex hash, go through each vertex to count how long it takes to get other vetices.\n<!-- Describe your approach to solving the problem. -->\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\n```\nclass Solution:\n    def countOfPairs(self, n: int, x: int, y: int) -> List[int]:\n        ans = [0] * n\n        \n        vert_hash = defaultdict(list)\n        for i in range(n):\n            if i - 1 >= 0:\n                vert_hash[i].append(i-1)\n            if i + 1 < n:\n                vert_hash[i].append(i+1)\n            if i == x - 1 and x != y:\n                vert_hash[i].append(y-1)\n            if i == y - 1 and x != y:\n                vert_hash[i].append(x-1)\n\n        for ele in range(n):\n            curr_idx = 0\n            q = deque(vert_hash[ele])\n            visited = {ele}\n            while q and len(visited) != n:\n                curr_len = len(q)\n                for _ in range(curr_len):\n                    curr_node = q.popleft()\n                    if curr_node in visited:\n                        continue\n                    else:\n                        ans[curr_idx] += 1\n                        q.extend(vert_hash[curr_node])\n                        visited.add(curr_node)\n                curr_idx += 1\n\n        return ans\n\n```
['Python3']