public static int[] encodeArray(final int i) {
return Integer.toString(i).chars().map(x -> x - '0').flatMap(digit -> {
if (digit < 0) return IntStream.of(-1); // sign: '-'
final Builder builder = IntStream.builder();
for (int x = 0; x < digit; x++) builder.accept(0);
builder.accept(1);
return builder.build();
}).toArray();
}
Comments
0 B
|👍
/👎