Skip to content

Commit 35fe776

Browse files
authored
Create Find First Palindromic String in the Array.java
1 parent c290f14 commit 35fe776

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution {
2+
public String firstPalindrome(String[] words) {
3+
return Arrays.stream(words).filter(Solution::isPalindrome).findFirst().orElse("");
4+
}
5+
6+
public static boolean isPalindrome(String s) {
7+
return new StringBuilder().append(s).reverse().toString().equals(s);
8+
}
9+
}

0 commit comments

Comments
 (0)