Math, asked by laxmi2023, 10 months ago

Find all pairs of distinct indices (i,j) in the given list such that concatenation of the two words, i.E. A[i] + a[j] is a palindrome.

Answers

Answered by Anonymous
7

Answer:

Input: ["abcd","dcba","lls","s","sssll"]

Output: [[0,1],[1,0],[3,2],[2,4]]

Explanation: The palindromes are ["dcbaabcd","abcddcba","slls","llssssll"]

Example 2:

Input: ["bat","tab","cat"]

Output: [[0,1],[1,0]]

Explanation: The palindromes are ["battab","tabbat"]

Similar questions