Pregunta de entrevista de Dropbox

Leetcode medium question from arrays.