You are given an integer n representing an array colors of length n where all elements are set to 0's meaning uncolored. You are also given a 2D integer array queries where queries[i] = [indexi, colori]. For the ithquery:
Set colors[indexi] to colori.
Count adjacent pairs in colors set to the same color (regardless of colori).
Return an array answer of the same length as queries where answer[i] is the answer to the ith query.
Since at each query, only one element is being recolored, we just need to focus on its neighbors.
Hint 2
If an element that is changed on the i-th query had the same color as its right element answer decreases by 1. Similarly contributes its left element too.
Hint 3
After changing the color, if the element has the same color as its right element answer increases by 1. Similarly contributes its left element too.