Question d’entretien chez Google

I got dynamic programming question,