#2672

Number of Adjacent Elements With the Same Color

specialist · 760 · lc medium +31 · 58.6% accepted · 397 likes · top 55%

Description

You have an array colors of length n initially all 0 (uncolored). Process queries where each [index, color] sets colors[index] = color. After each assignment, count adjacent pairs with equal non-zero colors. Return all counts as an array.

Code

1
2
3