what is the most efficient way to check a string palindrome in python Complexity wise ( Competitive Programming )

前端 未结 0 1526
清酒与你
清酒与你 2020-12-21 17:45

method 1:

s == s[::-1]

method 2:

n=len(s)
flag=True
for i in range(n//2):
    if(s[i]!=s[n-i-1]):
       flag=False
       break
i         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题