Jump Trading Interview Question

Dynamic programming + some language related tricks