FastPrepPalindrome Pairs
Problems/Palindrome Pairs

Palindrome Pairs

Airbnb logoAirbnb● HardINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in Airbnb software engineer intern technical interviews in 2017. The task was to find every ordered pair of different words that form a palindrome when joined.

The reports name the problem but give no limits, examples, or output order. Here, we use common limits and return the pairs sorted by the first index, then the second.

Our version is about 90% the same as the reported question.

You are given an array of distinct strings words.

A palindrome pair is a pair of indices [i, j] such that:

  • 0 <= i, j < words.length,
  • i != j, and
  • words[i] + words[j] (the two strings joined together) is a palindrome.

A palindrome reads the same forward and backward. The empty string is a palindrome.

Return all palindrome pairs. [i, j] and [j, i] are different pairs, and each one is listed only when it works. Sort the pairs by i, then by j, both in increasing order.

Function

palindromePairs(words: String[]) → List<List<Integer>>

Examples

Example 1

words = ["code","edoc","da","d"]return = [[0,1],[1,0],[2,3]]

"code" + "edoc" gives "codeedoc" and "edoc" + "code" gives "edoccode". Both read the same in both directions, so [0,1] and [1,0] count.

"da" + "d" gives "dad", so [2,3] counts. The other order, "dda", does not. No other pair works.

Example 2

words = ["a","","aa"]return = [[0,1],[0,2],[1,0],[1,2],[2,0],[2,1]]

Joining the empty string with a palindrome leaves that palindrome, so [0,1], [1,0], [1,2] and [2,1] count. Joining "a" and "aa" in either order gives "aaa", so [0,2] and [2,0] count too. All six ordered pairs work, listed by first index and then second index.

Example 3

words = ["abc","xyz"]return = []

"abcxyz" and "xyzabc" are not palindromes, so there are no pairs.

Constraints

  • 1 <= words.length <= 5000
  • 0 <= words[i].length <= 300
  • words[i] contains only lowercase English letters.
  • All strings in words are distinct.

More Airbnb Phone Screen questions

  • Read Across Sound TracksPHONE SCREEN · Seen Nov 2026
  • Text JustificationPHONE SCREEN · Seen Nov 2026
  • Decode and Store StringsPHONE SCREEN · Seen Oct 2026
  • Print Sentences as TablePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Detonate Bombs with Chain ReactionsPHONE SCREEN · Seen Aug 2026
  • Smallest Common RegionPHONE SCREEN · Seen Aug 2026
  • Longest Chain BookingPHONE SCREEN · Seen Aug 2026
  • Nested List Iterator with RemovePHONE SCREEN · Seen Jul 2026
  • Parse Query StringPHONE SCREEN · Seen May 2026
  • Pacific Atlantic Water FlowPHONE SCREEN · Seen May 2023

Similar questions at other companies

  • Highlight and Rank Overlapping CitationsHarvey · PHONE SCREEN · ONSITE INTERVIEWHarvey interview questions
  • Word Break IIAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Word Break IIWex · PHONE SCREEN
  • Word Break IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Design File SystemGoogle · PHONE SCREENGoogle interview questions
  • Phrase Covering the Most WordsZip · PHONE SCREENZip interview questions
  • Indexed API Field Pattern QueriesStripe · PHONE SCREENStripe interview questions
  • Find Repeated Substrings Ignoring CaseDatadog · PHONE SCREENDatadog interview questions
  • Common Words from Two ReadersAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Extract Company Tickers from NewsSusquehanna International Group (SIG) · ONSITE INTERVIEWSusquehanna International Group (SIG) interview questions

Interview reports that mention this question

  • Airbnb Intern Phone Interviews: 21 Experiences (Part 7 of 7)
  • Airbnb Intern OA and Phone Screens: 17 Experiences (Part 6 of 7)

Airbnb interview experiences

  • Airbnb SWE OA: Four-Level Banking System: 1 Experience
  • Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
  • Airbnb Intern OA and Onsite Rounds: 16 Experiences (Part 5 of 7)
  • Airbnb Intern OA, Diplomacy Game: 19 Experiences (Part 4 of 7)
All Airbnb interview questionsSee Airbnb hiring insights
Saved
class Solution {
    public List<List<Integer>> palindromePairs(String[] words) {
      // Write your code here.
    }
}
Checking account…