0457. Circular Array Loop
Description
**Input:** nums = [2,-1,1,2,2]
**Output:** true
**Explanation:**
There is a cycle from index 0 -> 2 -> 3 -> 0 -> ...
The cycle's length is 3.ac
Last updated
**Input:** nums = [2,-1,1,2,2]
**Output:** true
**Explanation:**
There is a cycle from index 0 -> 2 -> 3 -> 0 -> ...
The cycle's length is 3.Last updated
**Input:** nums = [-1,2]
**Output:** false
**Explanation:**
The sequence from index 1 -> 1 -> 1 -> ... is not a cycle because the sequence's length is 1.
By definition the sequence's length must be strictly greater than 1 to be a cycle.**Input:** nums = [-2,1,-1,-2,-2]
**Output:** false
**Explanation:**
The sequence from index 1 -> 2 -> 1 -> ... is not a cycle because nums[1] is positive, but nums[2] is negative.
Every nums[seq[j]] must be either all positive or all negative.