I am not able to get the correct answer please help

follow this Approach

We create two arrays - β€˜inc’ and β€˜dec’

  1. inc[i] stores the length of increasing subarray till i.
  2. dec[i] stores the length of decreasing subarray starting from index i.
  3. Doing so gives us the length of increasing and decreasing subarray at each index in O(n) time.
  4. We calculate the length of the longest bitonic subarray by finding the maximum inc[i] + dec[i] - 1
  5. We subtract one since the current element at ith index is included in both the increasing and decreasing subarray lengths.