Leaderboard
Showing:
Handle Score
@Ibrahim Nash 5725
@blackshadows 5685
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Complete Leaderboard
Type of array
Basic Accuracy: 19.99% Submissions: 95 Points: 1

You are given an array of size N having no duplicate elements. The array can be categorized into 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
Explanation:
Descending rotated with maximum
element 5 


Example 2:

Input :
N = 5
A[] = { 3, 4, 5, 1, 2}
Output : 
5 4
Explanation:
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)


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



 

 

to report an issue on this page.

Editorial

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

Yes

All Submissions

My Submissions:

Login to access your submissions.

Type of array

Output Window