Subscribe Us

Responsive Advertisement

Advertisement

beecrowd | 1069 Diamonds and Sand solution in cpp

 

beecrowd | 1069  Diamonds and Sand solution in cpp

by ujjal roy




#include<bits/stdc++.h>

using namespace std;

main()

{

    string s;

    int i,t;

    cin>>t;

    while(t--)

    {

        cin>>s;

   int c=0,ans=0;

   for(i=0;i<s.size();i++)

   {

       if(s[i]=='<') c++;

       else if(s[i]=='>')

       {

           if(c>0)

           {

               ans++;

                 c--;

           }


       }


   }

cout<<ans<<endl;

    }

}


Post a Comment

0 Comments