Find the position following the peak condition and have maximum leftIncreasing [ i ] + rightIncreasing [ i ]
for ( int i = 0 ; i < n ; i ++ ) { if ( leftIncreasing [ i ] != 0 && rightIncreasing [ i ] != 0 ) { result = max ( result , leftIncreasing [ i ] + rightIncreasing [ i ] ) ; } } return n - ( result + 1 ) ; }