Skip to content

Commit a9ac6c3

Browse files
committed
leetcode_2108
1 parent f71eca1 commit a9ac6c3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public:
3+
string firstPalindrome(vector<string>& words) {
4+
ios_base::sync_with_stdio(false);
5+
cin.tie(NULL);
6+
for(string& word : words){
7+
if(isPalindromic(word))
8+
return word;
9+
}
10+
return "";
11+
}
12+
bool isPalindromic(string& s){
13+
int i=0, j=s.size()-1;
14+
while(i < j){
15+
if(s[i]!=s[j])
16+
return 0;
17+
i++;
18+
j--;
19+
}
20+
return 1;
21+
}
22+
};

0 commit comments

Comments
 (0)