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.
and the check for length can be done before the loop
exactly, strange it got so many 'clever' votes.
A null input should either throw a NullPointerException (discouraged) or should gracefully delegate the null-handling back to the caller by returning null (prefered).
Converting null to an empty string (or any other "empty" object, for that matter) is a bad practice that leads to confusion in more complex code as to where exactly the unexpected "empty" dummy object originated from. An empty string is no different from any other empty object – it has no semantic value but is merely a meaningless stopgap. DON'T PRODUCE EMPTY OBJECTS!
I have not considered this yet. I believe if 2 (or more) solutions both have the shortest length, either one should be accepted, as the criteria states
"The shortest solution is the one containing the least nodes labeled 'P'."
So, they would both work. I will add this later, thanks.
Thanks but don't deserve an issue that are for rather big problems:-)
Already written :
2) The encode method should return an empty String if a null parameter is passed.