class Solution:
def firstPalindrome(self, words: List[str]) -> str:
for w in words:
if w == w[::-1]:
return w
return ""Where is the size of the string array and is the average length of a word in the array.
class Solution:
def firstPalindrome(self, words: List[str]) -> str:
for w in words:
l, r = 0, len(w) - 1
while w[l] == w[r]:
if l >= r:
return w
l, r = l + 1, r - 1
return ""Where is the size of the string array and is the average length of a word in the array.