Google interview question

Mostly around heaps, backtracking and dynamic programming.