-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchefsign.cpp
More file actions
56 lines (53 loc) · 918 Bytes
/
Copy pathchefsign.cpp
File metadata and controls
56 lines (53 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<iostream>
#include<cstring>
using namespace std;
long long int longestSequence(char s[],long long int n)
{
long long int longest=0;
long long int length=1;
for(long long int i=1;i<n;i++)
{
if(s[i]==s[i-1])
{
length++;
}
else
{
length=1;
}
if(length>longest)
{
longest=length;
}
}
return longest;
}
int main()
{
long long int t;
cin>>t;
while(t--)
{
string s;
cin>>s;
long long int x=s.length();
char arr[1000000];
long long int m=0;
for(long long int i=0;i<x;i++)
{
if(s[i]=='>'||s[i]=='<')
{
arr[m++]=s[i];
}
}
if(m==0)
cout<<"1"<<endl;
else if(m==1)
{
cout<<"2"<<endl;
}
else
cout<<longestSequence(arr,m)+1<<endl;
}
return 0;
}