Domanda di colloquio di Tesla

Leetcode "hard" programming question, dynamic programming related.