-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroli.cpp
62 lines (56 loc) · 1.28 KB
/
roli.cpp
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
57
58
59
60
61
62
// roli.cpp
// Two - Characters
// Author - R-07.
// profile - https://github.com/rahulbordoloi
// question link - https://www.hackerrank.com/challenges/two-characters/problem
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fi(i,a,b) for(i=a;i<=b;i++)
#define fr(i,a,b) for(i=a;i>b;i--)
#define endl '\n'
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;
/*common variables
ll t=0;
char s[t];
*/
ll alt(ll t, char *s)
{
ll i,j,k; // iterators
ll a=0; // trash
fi(i,'a','z')
{
fi(j,'a','z')
{
if(i!=j)
{
ll c=0;
fi(k,0,t-1)
{
if(*(s+k)==i || *(s+k)==j)
{
if(c%2==0 && *(s+k)==i) c++;
else if(c%2==1 && *(s+k)==j) c++;
else{c = 0; break;}
}
}
if(c>1) a = max(a,c);
}
}
}
return a;
}
int main()
{
ll t;
cin>>t;
char s[t];
cin>>s;
cout<<alt(t,s);
}