Search
⌘K

Leetcode 3160. Find the Number of Distinct Colors Among the Balls

Given sequential recoloring queries on balls labeled in [0, limit], return after each update how many distinct (non-empty) colors are present. The core challenge is to efficiently track each ball's current color and maintain color frequencies under reassignments (e.g., with hash maps) to handle up to 1e5 queries without allocating arrays of size limit.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.