Quote:
Originally Posted by daveT
with your new version, you don't have to...
something in pseudo JS:
of course, there is a recursive version, but I think you can figure that one out.
We don't have to account for odd/even string lengths unless I'm mistaken. Imagine we have a string of length 3...
@ i = 0 we are comparing string[0] and string[2]
@ i = 1 (the middle index) we are comparing string[1] and string[1]
What about for a string of length 4?
@ i = 1 (the middle 2 indexes) we are comparing string[1] and string[2]
In the above scenario, imagine comparing a string of 'adda' to easily visualize a string of length 4 that should return true.
Your return true / return false has the same effect as my break/return truthyString.length == string.length but is a bit cleaner. It's been a while since I've used any for loops.
It's been my experience that most people are idiots. They barely progressed past for loops so testing them for a recursive version would be a fruitless endeavour. I'll post my recursive version tomorrow (or tonight if I don't pass out before then).
Actually @ return true/false inside for loop it doesn't. That was the the whole point of my break. Imagine a string of 'amba'. If i replaced if the if-else (break) with return true/false that would return true.
Last edited by Craggoo; 09-17-2016 at 05:39 AM.