# Find the Number of Distinct Colors Among the Balls (LeetCode 4222)
Interview drill note.
## Approach
Draw a tiny example; verify the first and last indices. Walk the constraints carefully, prefer O(n) or O(n log n), and verify edge cases (empty, single element, ties).
## Complexity
State time and space clearly; call out edge cases (empty input, duplicates, extremes).
## Practice tip
Rehearse the explanation out loud. An [undetectable AI interview copilot](https://www.linkjob.ai/interview-copilot/) helps keep structure under time pressure.
## Notes (r0124)
Disclosure: personal study notes; I am affiliated with Linkjob AI.