FunctionRacerProblemsRace

Word Pairs That Make a Mirror

HardHash mapsPython, JavaScript, TypeScript, Java, C++

All strings in words are different. Return every pair of positions [i, j] with i != j for which words[i] + words[j] reads the same from both ends. The pairs can come in any order.

The order inside a pair matters: [i, j] and [j, i] are two pairs, and each is listed only if its own joined string reads the same from both ends.

Example 1

words ["ab","cba","a",""]
returns [[0,1],[0,2],[2,3],[3,2]]

The joined strings are abcba, aba, and a twice: the empty string pairs with a on either side.

Example 2

words ["one","two"]
returns []

Neither onetwo nor twoone reads the same from both ends.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Hash maps problems