2-Sigma Interview Question

dynamic programming and code in python