Dynamic Programming in a nutshell