Pergunta de entrevista da empresa Samsung Electronics

Something to do with backtracking and optimization