Solutions to Stanford algorithms course exercises