2672. Number of Adjacent Elements With the Same Color
There is a 0-indexed array
numsof lengthn. Initially, all elements are uncolored (has a value of0).You are given a 2D integer array
querieswherequeries[i] = [indexi, colori].For each query, you color the index
indexiwith the colorcoloriin the arraynums.Return an array
answerof the same length asquerieswhereanswer[i]is the number of adjacent elements with the same color after theithquery.More formally,
answer[i]is the number of indicesj, such that0 <= j < n - 1andnums[j] == nums[j + 1]andnums[j] != 0after theithquery.
1 | class Solution { |