Exercise for coding interview