Maximum length Bitonic Subarray (Arrays)

only 2 test cases passed and iam getting a TLE.
PLSE look into the code.

since the constraints are large u cannot use O(n^2 )

an efficient algo:
Solution
Let us consider the array {12, 4, 78, 90, 45, 23} to understand the soultion.

  1. Construct an auxiliary array inc[] from left to right such that inc[i] contains length of the nondecreaing subarray ending at arr[i].
    For A[] = {12, 4, 78, 90, 45, 23}, inc[] is {1, 1, 2, 3, 1, 1}

  2. Construct another array dec[] from right to left such that dec[i] contains length of nonincreasing subarray starting at arr[i].
    For A[] = {12, 4, 78, 90, 45, 23}, dec[] is {2, 1, 1, 3, 2, 1}.

  3. Once we have the inc[] and dec[] arrays, all we need to do is find the maximum value of (inc[i] + dec[i] – 1).
    For {12, 4, 78, 90, 45, 23}, the max value of (inc[i] + dec[i] – 1) is 5 for i = 3.