[LeetCode]#2108. Find First Palindromic String in the Array
Environment: Python 3.8
Key technique: for, [::-1]
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.
Input: words = ["abc","car","ada","racecar","cool"]
Explanation: The first string that is palindromic is "ada".
Note that "racecar" is also palindromic, but it is not the first.
- Reverse input string
- If string == reversed string, return it.
- If no string and reversed string is equal, return ‘’
def firstPalindrome(self, words):
for i in words: