ION Group interview question

Balls puzzle Query to get duplicate email