Permutataion(Codility) impl in java