Pergunta de entrevista da empresa Google

Non-discloseable, but optimal solutions were priority tree for the first one and easy recursion for the second.