Exercise solutions from The Algorithm Design Manual, Second Edition, by Steven Skiena