Java solution of the CareerCup