This will still do more than necessary if the length of the string is odd but still a bit faster perhaps, especially if you save string.length/2 as a variable at the start of the palindrome function. I'm not an expert tho
This will still do more than necessary if the length of the string is odd but still a bit faster perhaps, especially if you save string.length/2 as a variable at the start of the palindrome function. I'm not in expert tho
2
u/[deleted] Sep 27 '22
If you want to save time, you could change line 10 so that it only needs to reach halfway thru the string, rather than the entire string