Search for a command to run...
You are given a circular integer array A of size N.
Since the array is circular:
The first and last elements are also considered adjacent
A conflict occurs at index i if:
A[i] is equal to at least one of its neighboring elements
You must remove exactly one element from the array
After removal, the remaining array still stays circular
Return the minimum possible number of conflict positions in the resulting array
A single integer array A
A single integer representing the minimum possible conflict score
2≤N≤1000002 \le N \le 1000002≤N≤100000
1≤A[i]≤1000001 \le A[i] \le 1000001≤A[i]≤100000
Input:
1 2 2 3Output:
0Explanation: If we remove one of the 2s, the remaining circular array has no adjacent equal elements.
Example 1
[1, 2, 2, 3]0Example 2
[4, 4, 4, 4, 4, 4, 4]3Example 3
[1, 1, 2, 2, 3, 3]1[1, 2, 2, 3]
0