Find First Palindromic String in the Array
给一个字符串组, 找到第一个回文
class Solution {
public String firstPalindrome(String[] words) {
for(String w : words){
if(isPal(w))
return w;
}
return "";
}
public boolean isPal(String s) {
int i = 0;
int j = s.length() - 1;
while(i <= j){
if(s.charAt(i) != s.charAt(j))
return false;
i++;
j--;
}
return true;
}
}