Is the code below code good for checking whether a string is palindrome or not?
What is its time complexity? I guess it's,
s1 = 'abccba'
s2 = s1[::-1]
print 'Not Palindrome'
def check_palin(word): for i in xrange(len(word)/2): if word[i] != word[-(i+1)]: return False return True
I guess this is a bit more efficient solution as it iterates over half of the string and returns
False whenever the condition is violated. But still the complexity would be