#83. 检查相邻特定数字对

    ID: 83 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-2gesp3一维数组循环结构

检查相邻特定数字对

Adjacent Pair Check

Background

Dawei and Xiaoxiao are playing a number game. They have an array of integers and need to determine if specific adjacent pairs exist in the array.

Problem Description

Given an array of integers, return true if the array contains a 22 next to a 22 or a 44 next to a 44, but not both.

Input Format

Input is given from standard input in the following format.

A single line containing space-separated integers, representing the array elements.

Output Format

Output to standard output in the following format.

Output true if the condition is met; otherwise, output false.

Sample

1 2 2
true
4 4 1
true
4 4 1 2 2
false

Sample Explanation

Sample 1: The array [1, 2, 2] contains adjacent 2,22, 2 but not adjacent 4,44, 4, so it returns true. Sample 2: The array [4, 4, 1] contains adjacent 4,44, 4 but not adjacent 2,22, 2, so it returns true. Sample 3: The array [4, 4, 1, 2, 2] contains both adjacent 4,44, 4 and adjacent 2,22, 2, so it returns false.

Constraints

Time limit: 1s, Memory limit: 1024KiB for each test case.