Question: Write a function that receives a StaticArray and returns an integer that describes whether the array is sorted. The method must return: 1 if the

Write a function that receives a StaticArray and returns an integer that describes whether
the array is sorted. The method must return:
1 if the array is sorted in strictly ascending order.
-1 if the list is sorted in strictly descending order.
0 otherwise.
Arrays consisting of a single element are considered sorted in strictly ascending order.
You may assume that the input array will contain one or more homogeneous elements
(either all numbers, or strings, or custom objects, but never a mix of these). You do not
need to write checks for these conditions.
The original array must not be modified.
For full credit, the function must be implemented with O(N) complexity, with no additional
data structures (including Static Arrays) being created.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!