class Solution {
public String firstPalindrome(String[] words) {
for (String word : words) {
if (isPalindrome(word)) {
return word;
}
}
return "";
}
public boolean isPalindrome(String s) {
int left = 0;
int right = s.length() - 1;
while (left < right) {
if (left < right && s.charAt(left) != s.charAt(right)) {
return false;
}
left++;
right--;
}
return true;
}
}ja