https://ide.codingblocks.com/s/103861
how to do this problem in O(n) complexity?
Maximum length Biotonic Subarray doubt
You can take two arrays, incr and decr, and calculate their values, based on the fact, to determine wheather the given array is having elements in increasing order or in decreasing order, and then calculate the max of incr and decr values. You can calculate incr[ ] values while traversing array from beginning till end and comparing ar[i+1] and ar[i]; whereas for decr[ ] values, you need to traverse from end till beginning and check similarly. Then you need to calculate max values.
1 Like
can u pls write the pseudo code ?