Crossover for Work interview question

A code sample to determine output result.