Input: N = 6, Q[4][] = {{1, 3}, {4, 6}, {3, 4}, {3, 3}}
Output: 3
Explanation:
Initial array: arr[] = { 0, 0, 0, 0, 0, 0 }
Query 1: updated arr[] = { 1, 1, 1, 0, 0, 0 }.
Query 2: updated arr[] = { 1, 1, 1, 1, 1, 1 }.
Query 3: updated arr[] = { 1, 1, 2, 2, 1, 1 }.
Query 4: updated arr[] = { 1, 1, 3, 2, 1, 1 }.
The subarray { 1, 3, 2 } is minimum subarray which contains all unique elements. Thus, the answer is 3.
Input: N = 8, Q[6][] = {{1, 4}, {3, 4}, {4, 5}, {5, 5}, {7, 8}, {8, 8}}
Output: 4
Explanation:
After processing all queries, the array becomes = { 1, 1, 2, 3, 2, 0, 1, 2 }.
The subarray { 3, 2, 0, 1 } is minimum subarray which contains all unique elements. Thus, the answer is 4.