• + 2 comments

    Agree with you on all comments except for toCharArray() and the failing part.


    toCharArray() is wasteful here since it creates a new array (a copy) and allocates memory to store all the characters from the string. For small strings, this might not be an issue, but for longer ones you're wasting both time and space. Look at this post regardin the performance of using charAt(i) vs toCharArray() for character iteration.


    The failing part is handled already in my routine (look at the !failed part in my for loop condiiton). I'd usually prefer a single return statement in a method rather than having multiple points exiting the routine.