Given array A of N (N <= 106 ) elements (Ai <= 109 ). Given Q queries (Q <= 106 ). Every query consist of number K (K <= 109 ). For every query find number of subsegments such that their maximum element is K.
Test case:
5
1 2 3 4 3
3
2
3
4
Output:
2 -> [2], [1,2]
4 -> [1,2,3], [2,3], [3], [3]
8 -> [1,2,3,4], [1,2,3,4,3], [2,3,4], [2,3,4,3], [3,4], [3,4,3], [4], [4,3]