Merge API interview question

Leetcode Medium but multiple steps/phases