Pregunta de entrevista de Trade Terminal

medium coding question at leetcode.