Just practicing algorithms in java