1
// samll trick: for plaindrome question always try to follow concept that if2
// corners are equal we need to only work on middle string to check whether it3
// is also palindrome, instead of check complete strings(both given strings).6
bool ispalind(string x, int i, int j) {8
if (x[i] != x[j]) return false;14
bool checkpositions(string a, string b) {15
int i = 0, j = b.size() - 1;17
if (a[i] != b[j]) break;24
"ulacfd" ul.zalu //to check for palindrome : za(from b)25
"jizalu" ji.acfd //to check for palindrome : ac(from a)30
"ulacfd" jiza.fd //to check for palindrome : za(from b)31
"jizalu" ulac.lu //to check for palindrome : ac(from a)33
return ispalind(a, i, j) || ispalind(b, i, j);35
bool checkPalindromeFormation(string a, string b) {36
// cut one(from left) //cut two(from right)37
return checkpositions(a, b) || checkpositions(b, a);