Autodesk interview question

Leetcode Hard, a minmax optimisation problem.