Crossover for Work Interview Question

Leetcode style, medium difficulty question.