#115. 统计数组中的连续相同元素块
统计数组中的连续相同元素块
Count Clumps in Array
Background
Congcong is organizing a batch of data. He noticed that some data elements are consecutively repeated, and he wants to know how many such consecutive blocks there are.
Problem Description
Say that a "clump" in an array is a series of 2 or more adjacent elements of the same value. Return the number of clumps in the given array.
Input Format
Input is given from standard input in the following format.
An integer array, where elements are separated by spaces and enclosed in square brackets.
Output Format
Output is printed to standard output in the following format.
A single integer, representing the number of clumps in the array.
Sample
[1 2 2 3 4 4]
2
[1 1 2 1 1]
2
[1 1 1 1 1]
1
Sample Explanation
Sample 1: In the array [1 2 2 3 4 4], 2 2 is one clump and 4 4 is another clump, totaling clumps.
Sample 2: In the array [1 1 2 1 1], the first 1 1 is one clump, and the second 1 1 is another clump, totaling clumps.
Sample 3: In the array [1 1 1 1 1], all 1s form a single clump, totaling clump.
Constraints
Time limit: second, Memory limit: KiB for each test case.