Last active
April 14, 2020 18:02
-
-
Save lakshyabatman/7b6e534144d20569e3ee52428eb91d35 to your computer and use it in GitHub Desktop.
DOUBT, need help!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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