FastPrepFastPrep
Problem Brief

Cyclic Shift to Strictly Descending Array

FULLTIMEOA

Complete the function below. The function receives the full standard input as a single string and must return the exact standard output value for the described problem.

Original prompt

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

Function Description

Complete solveOneCyclicShiftStrictlyDescending. It has one parameter, String input, containing the full stdin payload. Return the exact stdout value as a string, either "true" or "false".

1Example 1

Input
input = "3\n3 2 1\n0"
Output
"true"
Explanation

The returned string must match the expected standard output for the sample input.

Constraints

Limits and guarantees your solution can rely on.

Use the limits and requirements stated in the prompt.

public String solveOneCyclicShiftStrictlyDescending(String input) {
    // write your code here
}
Input

input

"3\n3 2 1\n0"

Output

"true"

Sign in to submit your solution.