Company: Cisco_31_jan
Difficulty: medium
Count Bitonic Subsequences Count Bitonic Subsequences For a sequence to be bitonic : It must contain at least three elements. It must first strictly increase (each element greater than the previous). It must then strictly decrease (each element less than the previous). Examples of bitonic sequences: [100, 200, 100] , [100, 200, 300, 50] , and [100, 200, 50, -100] . Examples of non-bitonic sequences: [1, 2, 2, 1] , [1, 2, 3] , and [3, 2, 1] . A subsequence of an array can be derived by removing zero or more elements without altering the order of the remaining elements. Given an array arr of size n , determine the number of non-empty bitonic subsequences within arr . Since the result can be very large, return the value modulo (10 9 + 7). Example 1 Input: n = 5, arr = [1, 2, 3, 2, 1] Output: 11 Explanation: The 11 bitonic subsequences are [1, 2, 1], [1, 2, 1], [1, 3, 1], [1, 3, 2], [2, 3, 2], [2, 3, 1], [1, 2, 1], [1, 2, 3, 2, 1], [1, 2, 3, 2], [1, 2, 3, 1], [1, 2, 3, 2, 1]. Return 11. Ex