Lyft interview question

Standard Leetcode Medium DP problem