Algorithms for Interview (in Java)