Palindrome Pairs
Hard Accuracy: 35.22% Submissions: 514 Points: 8

Given an array of strings arr[] of size N, find if there exists 2 strings arr[i] and arr[j] such that arr[i]+arr[j] is a palindrome i.e the concatenation of string arr[i] and arr[j] results into a palindrome.

Example 1:

Input:
N = 6
arr[] = {"geekf", "geeks", "or","keeg", "abc",
"bc"}
Output: 1
Explanation: There is a pair "geekf"
and "keeg".


Example 2:

Input:
N = 5
arr[] = {"abc", "xyxcba", "geekst", "or", "bc"}
Output: 1
Explanation: There is a pair "abc"
and "xyxcba".


You don't need to read input or print anything. Your task is to complete the function palindromepair() which takes the array arr[], its size N and returns true if palindrome pair exists and returns false otherwise.
The driver code itself prints 1 if returned value is true and prints 0 if returned value is false.

Expected Time Complexity: O(N*l2) where l = length of longest string in arr[]
Expected Auxiliary Space: O(N*l2) where l = length of longest string in arr[]

Constraints:
1 ≤ N ≤ 104

1 ≤ |arr[i]| ≤ 10

We are replacing the old Disqus forum with the new Discussions section given below.