Skip to content

Commit 42e147f

Browse files
committed
Updated
1 parent df91692 commit 42e147f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
public class Solution {
2+
3+
public String firstPalindrome(String[] words) {
4+
for (int i = 0; i < words.length; i++) {
5+
String word = words[i];
6+
int x = 0, y = word.length() - 1;
7+
while (word.charAt(x) == word.charAt(y)) {
8+
if (x >= y)
9+
return word;
10+
else {
11+
x++;
12+
y--;
13+
}
14+
}
15+
}
16+
return "";
17+
}
18+
19+
}

0 commit comments

Comments
 (0)