Pergunta de entrevista da empresa MerQube

coding question leetcode, do medium to hard