Pergunta de entrevista da empresa BitTitan

a coding question using dynamic programming