algorithms practicing ( java )