3160. Find the Number of Distinct Colors Among the Balls
You are given an integer
limitand a 2D arrayqueriesof sizen x 2.There are
limit + 1balls with distinct labels in the range[0, limit]. Initially, all balls are uncolored. For every query inqueriesthat is of the form[x, y], you mark ballxwith the colory. After each query, you need to find the number of distinct colors among the balls.Return an array
resultof lengthn, whereresult[i]denotes the number of distinct colors afterithquery.Note that when answering a query, lack of a color will not be considered as a color.
1 | class Solution { |