Pregunta de entrevista de ByteDance

Random leetcode question, do more practice