Skip to content

Instantly share code, notes, and snippets.

@lakshyabatman
Last active April 14, 2020 18:02
Show Gist options
  • Save lakshyabatman/7b6e534144d20569e3ee52428eb91d35 to your computer and use it in GitHub Desktop.
Save lakshyabatman/7b6e534144d20569e3ee52428eb91d35 to your computer and use it in GitHub Desktop.
DOUBT, need help!
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string Lapindrome(string input) {
int size = input.length();
int half = size/2;
string secondHalf, firstHalf;
if(size%2==0) {
firstHalf = input.substr(0,half);
secondHalf = input.substr(half,half);
}else {
firstHalf = input.substr(0,half);
secondHalf = input.substr(half+1,half);
}
// cout << firstHalf << " " <<secondHalf <<endl;
sort(secondHalf.begin(),secondHalf.end());
sort(firstHalf.begin(),firstHalf.end());
if(secondHalf == firstHalf) {
return "YES";
}
return "No";
}
int main() {
int test;
cin >> test;
for(int i=0;i<test;i++) {
string input;
cin >> input;
string result = Lapindrome(input);
cout << result <<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment