Pergunta de entrevista da empresa Merge API

Medium Leetcode-y question. Not on leetcode