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