Squarepoint Capital Interview Question

a dynamic programming leetcode problem