Pergunta de entrevista da empresa TikTok

A leetcode problem with medium difficulties.