#259. 统计数组中相邻特定数字对
统计数组中相邻特定数字对
Count Sixes
Background
Congcong is learning array operations. Dawei assigned him a task to count the occurrences of a specific pattern in an array.
Problem Description
Given an array of integers, return the number of times that two 's are next to each other in the array. Also count instances where the first number is and the second number is .
Input Format
Input is given from Standard Input in the following format.
A single line containing space-separated integers, representing the elements of the array.
Output Format
Output is printed to Standard Output in the following format.
A single integer, the total count.
Sample
[6 6 2]
1
[6 6 2 6]
1
[6 7 2 6]
1
Sample Explanation
Sample 1: The array is [6, 6, 2]. At indices and , the numbers and are adjacent, which satisfies the condition. The count is .
Sample 2: The array is [6, 6, 2, 6]. At indices and , the numbers and are adjacent, which satisfies the condition. The count is .
Sample 3: The array is [6, 7, 2, 6]. At indices and , the numbers and are adjacent, which satisfies the condition. The count is .
Constraints
Time limit: 1 second, Memory limit: 1024 KB.