Menu Close

Find the ways they can choose the sequence of dummy statues

After completing some serious investigation, Arif and Simon are now chilling themselves in the Ooty hills. Very soon Simon became bored. Simon lived entirely for his profession. We know he is a workaholic. So Simon wants to stop his vacation and get back to work. But after a tiresome season, Arif is in no mood to return soon. So to keep Simon engaged, he decided to give to pull the idea of restarting the admissions of the academy they started last year for the new academic year-2021. 

Now Simon and Arif have decided to start the new admissions to the academy. As a part of the first round, the applied students had to solve a small puzzle. The puzzle was very simple. Arif has arranged N dummy statues in some order of height Hi. 

Now Simon have made up the question asking to the applicants that In how many ways they can choose the sequence of consecutive dummy statues, where the tallest and shortest statue in the selected sequence is the same.

If you would like to get admission into his academy, your first step is to solve the question. Give it a try 🙂


Input:
First line of the input-number of test-cases.

For every test case, first line will contain n.Next line will contain n space separated integers denoting h. 

Output:
Print the required answer
#include <stdio.h>
#include<string.h>
int main()
{   
    int t,n,h,i,l=1,count;
    scanf("%d",&t);
    while(t--){
        l=1;
        count=0; 
        scanf("%d",&n);
        for(i=1;i<=n;i++)
        {
            scanf("%d",&h);
            if(h==l)
            {
                count+=2;
            }
           if(h>l)
           {
            l=h;
            count++;}
    }
        printf("%d\n",count);
    }
 return 0;
}

INPUT_1:
2
3
2  3  4
3
4  4  5

OUTPUT:
3
4


INPUT_2:
2
3
2  4  3
3
4  4  5

OUTPUT:
2
4



Morae Q!