#254. 查找数组中的连续序列123
查找数组中的连续序列123
Find Sequence 123
Background
Congcong is playing a number game recently.
Problem Description
Given an array of integers, return true if the sequence 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
trueif the sequence appears consecutively; otherwise, outputfalse.
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.