#254. 查找数组中的连续序列123

    ID: 254 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatWarmup-2gesp3一维数组字符串

查找数组中的连续序列123

Find Sequence 123

Background

Congcong is playing a number game recently.

Problem Description

Given an array of integers, return true if the sequence 1,2,31, 2, 3 appears consecutively in the array somewhere.

Input Format

Input is given from standard input in the following format.

A single line, containing the string representation of an integer array. For example, [1 2 3 4]. Elements in the array are integers, separated by spaces, and enclosed by square brackets [ and ].

Output Format

Output to standard output in the following format.

Output true if the sequence 1,2,31, 2, 3 appears consecutively; otherwise, output false.

Sample

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

Sample Explanation

Sample 1: The array [1 1 2 3 1] contains the consecutive sequence 1 2 3, so output true. Sample 2: The array [1 1 2 4 1] does not contain the consecutive sequence 1 2 3, so output false. Sample 3: The array [1 1 2 1 2 3] contains the consecutive sequence 1 2 3, so output true.

Constraints

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