BitTitan Interview Question

a coding question using dynamic programming