Codeforces 1324 B. Yet Another Palindrome Problem Solution
Solution in c++:
- ///**********ALLAH IS ALMIGHTY************///
- ///AH Tonmoy
- ///Department of CSE,23rd batch
- ///Islamic University,Bangladesh
- #include<iostream>
- using namespace std;
- int main()
- {
- int n,i,t,j,f,a[50000];
- cin>>t;
- while(t--)
- {
- cin>>n;
- f=0;
- for(i=1; i<=n; i++)
- cin>>a[i];
- for(i=1; i<n-1; i++)
- {
- for(j=i+2; j<=n; j++)
- {
- if(a[i]==a[j])
- {
- f=1;
- break;
- }
- if(f==1)
- break;
- }
- if(f==1)
- break;
- }
- if(f==1)
- cout<<"YES"<<endl;
- else
- cout<<"NO"<<endl;
- }
- }
No comments