dsdacscsacscscx dcvx sccsca scsacscas
Hi I would advice you to look into segment tree implementation which has been given in codeforces blog i don’t exactly remeber the link but this same problem has been discussed there.
please explain TC’s.
1st query is 1 3 which means we need to find sum of length of all subarray having:
1 as maximum -> ans = 1
2 as maximum -> ans= 3
3 as maximum -> ans=6