Let's say that we have a Collection<Integer>
or an int[]
(array) of numbers, and we would like to count the
groups of adjacent elements with the same value (clumps).
input | output |
---|---|
1,4,4,4,9,6,6,7 | 2 (4s and 6s) |
- Test for zero clusters.
- Test for one cluster of only two elements.
- Test for multiple clusters of only two elements.
- Test for multiple clusters where at least one cluster has more than two elements.