Crossover for Work interview question

Typical leetcode algorithms questions though hard ones.