How to check whether array is sorted and rotated.

With time complexity of linear time and constant auxiliary space. Your input will be array and output should be boolean.

Please someone help me in this problem.

Why none of you are sending me code.

Constraint linear time

Constant space

Give an example input and output.

Add the reference to this question.

Explain what solution you have in mind. Be precise.

1 Like

What does rotated means here. To check it it is sorted, directly use is_sorted(arr,arr+size) STL function

rotated means, suppose initially you have a sorted array and then you pick some let say 0 <= i <= n - 1 and put arr[0 to i] to the right of arr[i + 1 to n - 1].

ex : [1, 2, 3, 4, 5], then u rotate it at i = 2 so final array will be [4, 5, 1, 2, 3], you have to search in this array…If you want to learn more this will work

I know what rotated means. I was just not getting the reference here. Got it now. Thanks