My solution to the second homework of Princeton University Algorithms. (Scored 91.66 / 100 )