Ctrl K

First Mirror Word

Easy
You are given an array of words words. Find the first word, in order, that reads the same left to right and right to left (a palindrome), and return it. If there is no such word, return the empty string "".
Example 1
words=['tree', 'noon', 'kayak'] → 'noon'

"noon" reads the same both ways and comes before "kayak".

Example 2
words=['ab', 'x'] → 'x'

A one-letter word is a palindrome too.

Example 3
words=['map', 'top'] → ''

There are no palindromes, so the answer is the empty string.

Constraints
  • 1 ≤ len(words) ≤ 100
  • 1 ≤ len(words[i]) ≤ 100
  • Words consist of lowercase English letters
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsDistance to the Nearest Marker EasyRise and Fall Lineup EasyGlued from the First Words EasyA Subsequence of One Word Only MediumLongest Word by Crossing Out Medium
loading Python…
Input
words=['tree', 'noon', 'kayak']
Expected
'noon'

Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.