LeetCode 2108, Easy. Topics: Array, Two Pointers, String. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 20 parametrized pytest cases, and a playground notebook:
Problem
Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string "".
A string is palindromic if it reads the same forward and backward.
Examples
Explanation: The first string that is palindromic is “ada”. Note that “racecar” is also palindromic, but it is not the first.
Explanation: The first and only string that is palindromic is “racecar”.
Explanation: There are no palindromic strings, so the empty string is returned.
Constraints
1 <= words.length <= 100
1 <= words[i].length <= 100
words[i] consists only of lowercase English letters.
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
NeetCode All. Last modified on September 7, 2026