Pergunta de entrevista da empresa Thomson Reuters

Leetcode question, very basic, doable