7 kyu

Palindrome Pairs

60 of 711smepple

Description:

Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.

Examples:

["bat", "tab", "cat"] # [[0, 1], [1, 0]]
["dog", "cow", "tap", "god", "pat"] # [[0, 3], [2, 4], [3, 0], [4, 2]]
["abcd", "dcba", "lls", "s", "sssll"] # [[0, 1], [1, 0], [2, 4], [3, 2]]

Non-string inputs should be converted to strings.

Return an array of arrays containing pairs of distinct indices that form palindromes. Pairs should be returned in the order they appear in the original list.

Lists
Strings
Fundamentals

More By Author:

Check out these other kata created by smepple

Stats:

CreatedJun 28, 2016
PublishedJun 28, 2016
Warriors Trained1500
Total Skips27
Total Code Submissions4452
Total Times Completed711
Ruby Completions60
JavaScript Completions318
CoffeeScript Completions11
Python Completions365
Total Stars29
% of votes with a positive feedback rating85% of 200
Total "Very Satisfied" Votes150
Total "Somewhat Satisfied" Votes39
Total "Not Satisfied" Votes11
Total Rank Assessments8
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • smepple Avatar
  • suic Avatar
  • Haksell Avatar
  • ejini战神 Avatar
Ad