It's more efficient to compare r[beg] and r[end] directly than to construct a temporary string.
The tests should include failing test cases too, that is, strings which aren't palindromes.
The test cases are all of odd-lengths. An even-length palindrome should be included because palindrome implementations sometimes fail with even lengths but not odd, or vice versa.
The empty string should also be a test case, for the same reason.
1 comment
[ 0.27 ms ] story [ 11.9 ms ] threadThe tests should include failing test cases too, that is, strings which aren't palindromes.
The test cases are all of odd-lengths. An even-length palindrome should be included because palindrome implementations sometimes fail with even lengths but not odd, or vice versa.
The empty string should also be a test case, for the same reason.