Bank of America interview question

dynamic programming, brain teaser, etc.