Input: Q = 3, arr[] = {2, 2, 5, 5, 4, 6, 3}, queries[][] = {{1, 7}, {6, 8}, {7, 2}}
Output: {6, 6, 5}
Explanation:
The total distinct elements after each query (one-based indexing):
Query 1: p = 1 and x = 7. Therefore, arr[1] = 7 and arr[] becomes {7, 2, 5, 5, 4, 6, 3}. Hence, distinct elements = 6.
Query 2: p = 6 and x = 8. Therefore, arr[6] = 8 and arr[] becomes {7, 2, 5, 5, 4, 8, 3}. Hence, distinct elements = 6.
Query 3: p = 7 and x = 2. Therefore, arr[7] = 2 and arr[] becomes {7, 2, 5, 5, 4, 8, 2}. Hence, distinct elements = 5.
Input: Q = 2, arr[] = {1, 1, 1, 1}, queries[][] = {{2, 2}, {3, 3}}
Output: {2, 3}
Explanation:
The total distinct elements after each query (one-based indexing):
Query 1: p = 2 and x = 2. Therefore, arr[2] = 2 and arr[] becomes {1, 2, 1, 1}. Hence, distinct elements = 2.
Query 2: p = 3 and x = 3. Therefore, arr[3] = 3 and arr[] becomes {1, 2, 3, 1}. Hence, distinct elements = 3.