Question: // refer to the Java code here: // https://gist.github.com/rjlutz/3c26a1be877529de8dd28049d12415d0 // complete the dart implementation below to have the same functionality class Palindrome { // TODO
// refer to the Java code here: // https://gist.github.com/rjlutz/3c26a1be877529de8dd28049d12415d0 // complete the dart implementation below to have the same functionality
class Palindrome { // TODO implement check static check(String s) { return true; } }
// lambda to mimic Java's Character.isLetterOrDigit() bool isLetterOrDigit(String s, int idx) => s[idx].contains(RegExp(r'[\da-zA-Z]'));
main() { // should result in true,false,true,false,true,false print(Palindrome.check('radar')); print(Palindrome.check('raxdar'));
print(Palindrome.check('noon')); print(Palindrome.check('nxoon'));
print(Palindrome.check('Rise to vote, sir!')); print(Palindrome.check('Rise to xyz vote, sir!')); }
Requirements
Your app should have a Palindrome class
Your Palindrome class should have a public, one-arg static helper method named check
Your Palindrome class should have a private, three-arg static recursive method
Hints:
You can refer to https://gist.github.com/rjlutz/3c26a1be877529de8dd28049d12415d0 for the original java implementation
Your code should execute the tests in main() and result in an output of:
true
false
true
false
true
false
A lambda function has been provided to mimic Javas Character.isLetterOrDigit() method. You may use this if you wish.
Although the problem could be solved using global functions, follow the existing Java code pattern of a class with a static method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
