Pinterest interview question

A problem that combines binary search with dynamic programming.