#260. 检查数组中是否存在三连击

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

检查数组中是否存在三连击

Check for Triples

Background

Congcong is playing a number game. He needs to check if a sequence of numbers contains three consecutive identical numbers. If it does, he cannot pass the current level.

Problem Description

Given an array of integers, we define a "triple" as a value appearing 33 times in a row in the array. Return true if the array does not contain any triples; otherwise, return false.

Input Format

Input is given from standard input in the following format.

A single line containing multiple integers, representing the elements of the array. Elements are separated by spaces.

Output Format

Output is printed to standard output in the following format.

Output true if the array does not contain any triples; otherwise, output false.

Sample

[1 1 2 2 1]
true
[1 1 2 2 2 1]
false
[1 1 1 2 2 2 1]
false

Sample Explanation

  • Sample 1: The array is [1 1 2 2 1]. There are no three consecutive identical numbers, so the output is true.
  • Sample 2: The array is [1 1 2 2 2 1]. The number 22 appears three times consecutively, forming a "triple\