Interview questions suck. Here are a few algorithms, a toybox of bit and pieces in various languages that you might find in an interview. The best way to learn is to do it yourself, ingraining till it is reflexive. The other way is search-copy-paste. I make no guarantees to the correctness or even usefullness of this code.
Copyright (c) 2011-2014, Micah Jaffe Licensed for use under BSD License. http://www.opensource.org/licenses/bsd-license.php