
cyclicSequence
A sequence a1, a2, …, an
is called cyclic increasing if for some i (1 ≤ i ≤ n)
, ai, ai + 1, …, an, a1, a2, …, ai - 1
is an increasing sequence.
Given a sequence, check whether it is cyclic increasing.
Example
-
For
sequence = [5, 9, 1, 2, 4]
, the output should becyclicSequence(sequence) = true
.Increasing sequence can be started from number
1
. -
For
sequence = [1, 3, 2]
, the output should becyclicSequence(sequence) = false
.
Input/Output
-
[execution time limit] 0.5 seconds (cpp)
-
[input] array.integer sequence
Guaranteed constraints:
1 ≤ sequence.length ≤ 105
,-105 ≤ sequence[i] ≤ 105
. -
[output] boolean
true
ifsequence
is cyclic increasing,false
otherwise.
Post Comment