Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
"Same goes for all the other arrays/lists that you will get in the tests.."
finally somebody, who cares about clean, reader-friendly code :)
This comment is hidden because it contains spoiler information about the solution
Sure, and if my palindrome checking function ever becomes a time-critical component of the next NASA mission then I might want to consider re-writing it for better performance.
But until then I prefer to code with emphasis on readability.
although checking equalsIgnoreCase on reversed string is somehow clever,
we make a copy of the array, and then we reverse it, and on the top of that, if string is a palindrome,
algorightm would make double check on every character.
This could be avoidied by making iteration using str.chatAt(i) .. well .. but it wouldnt be so clean
But this solution, doest not handle case, when we find unchanged meerkats
"Something has gone terribly wrong - someone has gone and switched their heads and tails around!"
It does not say that "switched ALL their heads and tails around" ..
The only challange in this task is to understand business logic ...
But this solution, doest not handle case, when we find unchanged meerkats
"Something has gone terribly wrong - someone has gone and switched their heads and tails around!"
It does not say that "switched ALL their heads and tails around" ..
The only challange in this task is to understand business logic ...
string.toCharArray() underneath makes a copy of the String character array (defensive programming)
If we prepare array by making new char[string.lenth()] and then iterate trought string using chatAt(i) we could avoid one array copy