HackerEarth Xsquare And Double Strings problem solution YASH PAL, 31 July 2024 In this HackerEarth Xsquare And Double Strings problem solution, Xsquare got bored playing with the arrays all the time. Therefore, he has decided to play with the strings. Xsquare called a string P a “double string” if string P is not empty and can be broken into two strings A and B such that A + B = P and A = B. for eg : strings like “baba” , “blabla” , “lolo” are all double strings whereas strings like “hacker” , “abc” , “earth” are not double strings at all. Today, Xsquare has a special string S consisting of lower case English letters. He can remove as many characters ( possibly zero ) as he wants from his special string S. Xsquare wants to know , if its possible to convert his string S to a double string or not. Help him in accomplishing this task. HackerEarth Xsquare And Double Strings problem solution. #include <bits/stdc++.h>using namespace std ;#define LL long long int#define ft first#define sd second#define PII pair<int,int>#define MAXN 100005#define MAXM 10000001#define mp make_pair#define f_in(st) freopen(st,"r",stdin)#define f_out(st) freopen(st,"w",stdout)#define sc(x) scanf("%d",&x)#define scll(x) scanf("%lld",&x)#define pr(x) printf("%dn",x)#define pb push_back#define MOD 1000000007#define MAX 1000010#define ull long long#define prime 37#define pb push_back#define ASST(x,y,z) assert(x >= y && x <= z)int t , n;string s ;int main(){ f_in("in02.txt") ; f_out("out02.txt") ; sc(t) ; ASST(t,1,100) ; while(t --){ cin >> s ; n = s.length() ; ASST(n,1,100) ; int M[26]={0} , c = 0; for(int i=0;i<n;i++) ASST(s[i],'a','z') ; bool ok = false ; for(int i=0;i<n;i++) M[s[i]-'a'] ++ ; for(int i=0;i<26;i++) if(M[i] > 1) ok = true ; puts(ok ? "Yes" : "No") ; } return 0 ;} Second solution #include <bits/stdc++.h>using namespace std;int cnt[32];int main(){ int t; string s; cin >> t; while ( t-- ) { cin >> s; memset(cnt, 0, sizeof(cnt)); for ( int i = 0; i < s.size(); i++ ) cnt[s[i]-'a']++; for ( int i = 0; i < 26; i++ ) { if ( cnt[i] >= 2 ) { printf("Yesn"); goto p1; } } printf("Non"); p1: { } } return 0;} coding problems