Copied to Clipboard
Type of array
Basic Accuracy: 35.8% Submissions: 557 Points: 1

You are given an array of size N having no duplicate elements. The array can be categorized into the following:
1.  Ascending
2.  Descending
3.  Descending Rotated
4.  Ascending Rotated
Your task is to return which type of array it is and the maximum element of that array.


Example 1:

Input :
N = 5 
A[] = { 2, 1, 5, 4, 3}
Output :
5 3
Descending rotated with maximum
element 5 

Example 2:

Input :
N = 5
A[] = { 3, 4, 5, 1, 2}
Output : 
5 4
Ascending rotated with maximum element 5 


Your Task:  
You don't need to read input or print anything. Your task is to complete the function maxNtype() which takes the array A[] and its size N as inputs and returns the largest element in the array and and integer x denoting the type of the array.

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

3 <= N <= 105
1 <= A[] <= 1012



We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Type of array

Output Window