← 返回 bytedance 的题目列表Count Unique Colors After Each Ball Coloring Query
类型:online_judge
bytedance
There is a box containing balls labeled with numbers in the range [0, limit], and there are a total of limit + 1 balls. Given queries, which is a list of n x 2 elements where each query [x, y] means marking x balls with color y. You need to return the number of unique colors in all balls after each query. Implement this functionality.
Input
limit: An integer representing the maximum label of balls
queries: A 2D list of size n x 2, indicating the number of balls to be marked and the color.
Output
An integer list of length n which represents the count of unique colors after each query.
Example
limit = 5
queries = [[2, 1], [3, 2], [1, 3]]
Output
[1, 2, 3]
Data Constraints
1 <= n <= 1000
0 <= limit <= 1000
0 <= x <= limit
0 <= y <= 1000
Example
Input
5
[[2, 1], [3, 2], [1, 3]]