Solution Link to heading

The duality of this section is somewhat convoluted. Let us assume that the repeated digit is denoted by $k$. For the array nums, there are more than $k$ occurrences of numbers between $1$ and $k$. Therefore, for a given $mid$, if the count of numbers between $1$ and $mid$ exceeds $mid$, this indicates that $mid \geq k$, otherwise $mid < k$.

Two pointers Link to heading

Here, we can visualize the array as a singly-linked list. Index i of the array represents a pointer to the linked list node, while nums[i] represents a pointer to the next node. The presence of duplicate integers indicates the existence of a cycle in this linked list. Therefore, we can apply the two-pointer technique to find the entrance of the cycle.