Faster algorithm 452
Solved problem 451 base case