Final result #1

Open
Z.Gharagozloo.M wants to merge 7 commits from develop into main
Showing only changes of commit e2a62ea34e - Show all commits
+20 -4
View File
@@ -76,11 +76,27 @@ public class BonusExercises {
*/
public List<String> findPalindromes(String string) {
List<String> list = new ArrayList<>();
// todo
String regex = "[^a-zA-Z]+";
//Splitting the string by anything except words to check each one
String[] words = string.split(regex);
for (String word : words) {
if (word.length() >= 3) {
//Case-insensitive
String lower = word.toLowerCase();
String reversed = new StringBuilder(lower).reverse().toString();
//Checking if it's palindrome or not
if (lower.equals(reversed)) {
list.add(word);
}
}
}
return list;
}
public static void main(String[] args) {
// you can test your code here
}
public static void main(String[] args) {}
}