"Algorithm Notes" Hu Fan, the full version of the solution