#92. 判断数组是否存在连续递增三元组

    ID: 92 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-2gesp1循环结构条件结构

判断数组是否存在连续递增三元组

Consecutive Increasing Triplets

Background

Congcong is currently studying the properties of sequences. He wants to know if a certain special pattern exists within a sequence.

Problem Description

Return true if the array contains, somewhere, three increasing adjacent numbers like 4,5,64, 5, 6 or 23,24,2523, 24, 25. Otherwise, return false.

Input Format

Input is given from standard input in the following format.

The input consists of a single line containing a series of space-separated integers, representing the elements of the array.

Output Format

Output to standard output in the following format.

Output true if the array contains three consecutive increasing numbers; otherwise, output false.

Sample

[1 4 5 6 2]
true
[1 2 3]
true
[1 2 4]
false

Sample Explanation

  • Sample 1: The array contains 4,5,64, 5, 6, which are three consecutive increasing numbers, so the output is true.
  • Sample 2: The array contains 1,2,31, 2, 3, which are three consecutive increasing numbers, so the output is true.
  • Sample 3: The array does not contain three consecutive increasing numbers, so the output is false.

Constraints

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