Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
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.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.