Pregunta de entrevista de HeyGen

Standard leetcode question, probably medium difficulty