Company: Google_8nov
Difficulty: medium
Tricky Subarrays Problem Description You are given a permutation A of length N. Task: There are Q queries. In each query, you are given L and R. Determine the number of subsequences B from the subarray A[L...R] such that |B| = max(B). |B| is the length of the array B. Notes 1-based indexing is used in this question A permutation P of size N is an array where each number from 1 to N appears exactly once. A subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without changing the order of the remaining elements. An array B is called a subarray of A if it forms a contiguous subsequence of A, i.e., if it is equal to A L , A L+1 , ..., A R for some L, R. Function Description Complete the function TrickySubarrays provided in the editor. This function takes the following 4 parameters and returns the required answer: N: Represents the length of the permutation A A: Represents N space-separated integers denoting the permutation elements Q: Repr