← 返回 capitalone 的题目列表Check Whether a Cyclic Shift Can Make the Array Strictly Descending
类型:online_judge
Problem
Given an integer array nums of length n and an integer t (0 <= t < n). Define one cyclic shift as moving the last t elements of the array to the front (i.e., a right rotation by t).
Determine whether applying this shift once makes the array strictly descending.
Return true/false.
Note: The original description is slightly ambiguous about whether t is given or you may choose t. This version assumes t is given and you check the result after one shift.
Input
Integer array nums
Integer t
Output
true or false
Constraints (suggested)
1 <= n <= 2e5
0 <= t < n
-1e9 <= nums[i] <= 1e9
Examples
nums=[3,2,1], t=0 → true
nums=[1,3,2], t=1 → false
nums=[2,1,3], t=2 → false
nums=[4,3,2,1], t=1 → false
nums=[2,1], t=1 → false
Example
Input
3
3 2 1
0
Output
true