Sponsored
Use these hints if you're stuck. Try solving on your own first.
Use two HashMaps to maintain the color of each ball and the set of balls with each color.
Solve with full IDE support and test cases