Java solutions to Algorithm Problems