Search⌘ K
AI Features

Solution: Check if Array Is Sorted and Rotated

C# solution for the Check if Array Is Sorted and Rotated problem using the Knowing What to Track pattern.

Statement

Given an integer array nums, determine whether nums can be obtained by taking some array that is sorted in nondecreasing order and rotating it by some number of positions. Return true if such a rotation is possible, otherwise return false.

A rotation by x positions means shifting the array so that the last x elements move to the front, while preserving their relative order.

Note: A rotation by 00 positions is allowed.

Constraints:

  • 11 \leq nums.length ...