• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
May 25, 2022 |2.3K Views
Maximum Length Bitonic Subarray
  Share   Like
Description
Discussion

Given an array A[0 … n-1] containing n positive integers, a subarray A[i … j] is bitonic if there is a k with i <= k <= j such that A[i] <= A[i + 1] … = A[k + 1] >= .. A[j – 1] > = A[j]. Write a function that takes an array as argument and returns the length of the maximum length bitonic subarray. 
Expected time complexity of the solution is O(n)
Simple Examples 
1) A[] = {12, 4, 78, 90, 45, 23}, the maximum length bitonic subarray is {4, 78, 90, 45, 23} which is of length 5.
2) A[] = {20, 4, 1, 2, 3, 4, 2, 10}, the maximum length bitonic subarray is {1, 2, 3, 4, 2} which is of length 5.


Maximum Length Bitonic Subarray: https://www.geeksforgeeks.org/maximum-length-bitonic-subarray/

Read More