Is the code below code good for checking whether a string is palindrome or not?
What is its time complexity? I guess it's, O(1)
am I right? Because we are just accessing the same string with different indexes and so accessing index O(1)
is an operation. Please correct me if I'm wrong. Please provide a better solution, if possible.
s1 = 'abccba'
s2 = s1[::-1]
if s1==s2:
print('Palindrome')
else:
print('Not Palindrome')