2108. Find First Palindromic String in the Array Easy

@problem@discussion
#Array#Two Pointers#String



1/**
2 * [2108] Find First Palindromic String in the Array
3 *
4 * Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string "".
5 * A string is palindromic if it reads the same forward and backward.
6 *  
7 * Example 1:
8 * 
9 * Input: words = ["abc","car","ada","racecar","cool"]
10 * Output: "ada"
11 * Explanation: The first string that is palindromic is "ada".
12 * Note that "racecar" is also palindromic, but it is not the first.
13 * 
14 * Example 2:
15 * 
16 * Input: words = ["notapalindrome","racecar"]
17 * Output: "racecar"
18 * Explanation: The first and only string that is palindromic is "racecar".
19 * 
20 * Example 3:
21 * 
22 * Input: words = ["def","ghi"]
23 * Output: ""
24 * Explanation: There are no palindromic strings, so the empty string is returned.
25 * 
26 *  
27 * Constraints:
28 * 
29 * 	1 <= words.length <= 100
30 * 	1 <= words[i].length <= 100
31 * 	words[i] consists only of lowercase English letters.
32 * 
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/find-first-palindromic-string-in-the-array/
37// discuss: https://leetcode.com/problems/find-first-palindromic-string-in-the-array/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42    pub fn first_palindrome(words: Vec<String>) -> String {
43        String::new()
44    }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51    use super::*;
52
53    #[test]
54    fn test_2108() {
55    }
56}
57


Back
© 2025 bowen.ge All Rights Reserved.