Pergunta de entrevista da empresa Google

algorithm + logic twist, need to think about if there's ways to optimize it (not by swapping out data structure or algorithem but think outside the box)