RUPEEK Hiring | On-Campus OA (2022) | Check if Array Is Sorted and Rotated

Question · Posted Jun 2026

Problem Statement Given an integer array nums, determine whether it was originally sorted in non-decreasing order and then rotated some number of times (possibly zero). Duplicates may exist in the array. Return true if the array satisfies the condition, otherwise return false. Example Input nums = [3,4,5,1,2] Output true Explanation The array [1,2,3,4,5] is sorted. After rotating it 3 positions, we get: [3,4,5,1,2] Hence the answer is true. Constraints 1 <= nums.length <= 100 1 <= nums[i] <= 100

The full answer & interview discussion are available to premium members.

Log in Create a free account