#259. 统计数组中相邻特定数字对

    ID: 259 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatWarmup-2gesp3一维数组模拟

统计数组中相邻特定数字对

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 66's are next to each other in the array. Also count instances where the first number is 66 and the second number is 77.

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 00 and 11, the numbers 66 and 66 are adjacent, which satisfies the condition. The count is 11. Sample 2: The array is [6, 6, 2, 6]. At indices 00 and 11, the numbers 66 and 66 are adjacent, which satisfies the condition. The count is 11. Sample 3: The array is [6, 7, 2, 6]. At indices 00 and 11, the numbers 66 and 77 are adjacent, which satisfies the condition. The count is 11.

Constraints

Time limit: 1 second, Memory limit: 1024 KB.