Pergunta de entrevista da empresa JPMorganChase

Leet code medium level of difficulty