My solutions to interview question posted on http://www.geeksforgeeks.org/