Please solve the programming task below using a self-contained code snippet in a markdown code block.

You are given a positive integer n representing the number of nodes in a connected undirected graph containing exactly one cycle. The nodes are numbered from 0 to n - 1 (inclusive).
You are also given a 2D integer array edges, where edges[i] = [node1i, node2i] denotes that there is a bidirectional edge connecting node1i and node2i in the graph.
The distance between two nodes a and b is defined to be the minimum number of edges that are needed to go from a to b.
Return an integer array answer of size n, where answer[i] is the minimum distance between the ith node and any node in the cycle.
 
Please complete the following python code precisely:
```python
class Solution:
    def distanceToCycle(self, n: int, edges: List[List[int]]) -> List[int]:
```