import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class Main {
private static List<List<Integer>> dividir(int... array) {
List<Integer> lista = IntStream.of(array).boxed().collect(Collectors.toList());
return dividir(lista);
}
private static List<List<Integer>> dividir(List<Integer> lista) {
List<List<Integer>> resultado = new ArrayList<>();
List<Integer> parte = new ArrayList<>();
int elemento = i;
if (!parte.isEmpty() && (ultima == null || (elemento != ultima && elemento != ultima + 1))) {
resultado.add(parte);
parte = new ArrayList<>();
}
parte.add(elemento);
ultima = elemento;
}
if (!parte.isEmpty()) resultado.add(parte);
return resultado;
}
public static void main
(String[] args
) { int[] array = {1, 2, 2, 3, 3, 3, 6, 6, 7, 11, 12, 12, 13, 14, 14};
List<List<Integer>> lista = dividir(array);
}
}
aW1wb3J0IGphdmEudXRpbC5BcnJheUxpc3Q7CmltcG9ydCBqYXZhLnV0aWwuTGlzdDsKaW1wb3J0IGphdmEudXRpbC5zdHJlYW0uQ29sbGVjdG9yczsKaW1wb3J0IGphdmEudXRpbC5zdHJlYW0uSW50U3RyZWFtOwoKcHVibGljIGNsYXNzIE1haW4gewoKICAgIHByaXZhdGUgc3RhdGljIExpc3Q8TGlzdDxJbnRlZ2VyPj4gZGl2aWRpcihpbnQuLi4gYXJyYXkpIHsKICAgICAgICBMaXN0PEludGVnZXI+IGxpc3RhID0gSW50U3RyZWFtLm9mKGFycmF5KS5ib3hlZCgpLmNvbGxlY3QoQ29sbGVjdG9ycy50b0xpc3QoKSk7CiAgICAgICAgcmV0dXJuIGRpdmlkaXIobGlzdGEpOwogICAgfQoKICAgIHByaXZhdGUgc3RhdGljIExpc3Q8TGlzdDxJbnRlZ2VyPj4gZGl2aWRpcihMaXN0PEludGVnZXI+IGxpc3RhKSB7CiAgICAgICAgTGlzdDxMaXN0PEludGVnZXI+PiByZXN1bHRhZG8gPSBuZXcgQXJyYXlMaXN0PD4oKTsKICAgICAgICBMaXN0PEludGVnZXI+IHBhcnRlID0gbmV3IEFycmF5TGlzdDw+KCk7CiAgICAgICAgSW50ZWdlciB1bHRpbWEgPSBudWxsOwogICAgICAgIGZvciAoSW50ZWdlciBpIDogbGlzdGEpIHsKICAgICAgICAgICAgaW50IGVsZW1lbnRvID0gaTsKICAgICAgICAgICAgaWYgKCFwYXJ0ZS5pc0VtcHR5KCkgJiYgKHVsdGltYSA9PSBudWxsIHx8IChlbGVtZW50byAhPSB1bHRpbWEgJiYgZWxlbWVudG8gIT0gdWx0aW1hICsgMSkpKSB7CiAgICAgICAgICAgICAgICByZXN1bHRhZG8uYWRkKHBhcnRlKTsKICAgICAgICAgICAgICAgIHBhcnRlID0gbmV3IEFycmF5TGlzdDw+KCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcGFydGUuYWRkKGVsZW1lbnRvKTsKICAgICAgICAgICAgdWx0aW1hID0gZWxlbWVudG87CiAgICAgICAgfQogICAgICAgIGlmICghcGFydGUuaXNFbXB0eSgpKSByZXN1bHRhZG8uYWRkKHBhcnRlKTsKICAgICAgICByZXR1cm4gcmVzdWx0YWRvOwogICAgfQoKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgICAgICBpbnRbXSBhcnJheSA9IHsxLCAyLCAyLCAzLCAzLCAzLCA2LCA2LCA3LCAxMSwgMTIsIDEyLCAxMywgMTQsIDE0fTsKICAgICAgICBMaXN0PExpc3Q8SW50ZWdlcj4+IGxpc3RhID0gZGl2aWRpcihhcnJheSk7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKGxpc3RhKTsKICAgIH0KfQ==
[[1, 2, 2, 3, 3, 3], [6, 6, 7], [11, 12, 12, 13, 14, 14]]