Optiver interview question

Dynamic programming coding in python