Career Cup problem solutions in Java