Fractal Interview Question

Counting duplicates