-
Problem Name: Friendship in Wonderland
-
Difficulty Level: Medium Level
-
Editorial : Kirti (Medium)
-
Pre - Requites : Basic Knowledge of string and pattern matching. Problem solving skills would be an upvote if you have it.
-
Solution for the question is here:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin>>t;
while(t–)
{
string s;
cin>>s;
ll len = s.length();
ll k=(len)/2;
ll count=0;
for(ll i=1;i<k;i++)
{
ll j=k-i;
string s1=s.substr(0,i);
string s2=s.substr(i,i);
string s3=s.substr(2i,j);
string s4=s.substr(2i + j,j);
if(s1==s2 && s3==s4)
count++;
}
cout<<count<<"\n";
}
return 0;
}