Codeforces 1324 B. Yet Another Palindrome Problem Solution

Solution in c++:

  1. ///**********ALLAH IS ALMIGHTY************///
  2. ///AH Tonmoy
  3. ///Department of CSE,23rd batch
  4. ///Islamic University,Bangladesh
  5. #include<iostream>
  6. using namespace std;
  7. int main()
  8. {
  9.  
  10. int n,i,t,j,f,a[50000];
  11. cin>>t;
  12. while(t--)
  13. {
  14. cin>>n;
  15. f=0;
  16. for(i=1; i<=n; i++)
  17. cin>>a[i];
  18.  
  19. for(i=1; i<n-1; i++)
  20. {
  21. for(j=i+2; j<=n; j++)
  22. {
  23. if(a[i]==a[j])
  24. {
  25. f=1;
  26. break;
  27. }
  28. if(f==1)
  29. break;
  30. }
  31. if(f==1)
  32. break;
  33. }
  34. if(f==1)
  35. cout<<"YES"<<endl;
  36. else
  37. cout<<"NO"<<endl;
  38. }
  39. }

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.