F
Size: a a a
F
AM
F
AM
F
MG
AM
[1,1,2,1] becomes [[1,1],[2],[1]]?MG
AM
m not seeing ready-made solution for it, so it would probably be done via fold` operator.AN
m not seeing ready-made solution for it, so it would probably be done via fold` operator.groupBy{it}AN
groupBy{it}.valuesAL
list.groupBy { it }.values.toList() list.fold(mutableListOf<MutableList<Int>>()) { acc, current ->
acc.apply {
if (isEmpty() || last().first() != current) {
add(mutableListOf(current))
} else {
last() += current
}
}
}AM
groupBy{it}AN
AM
list.groupBy { it }.values.toList() list.fold(mutableListOf<MutableList<Int>>()) { acc, current ->
acc.apply {
if (isEmpty() || last().first() != current) {
add(mutableListOf(current))
} else {
last() += current
}
}
}MG
groupBy{it}.valuesAN
MG
group 0:
0
0
0
group 1:
1
1
group 2:
2
AM
AM