Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

check is symmetric python

# Kiem tra chuoi doi xung
import sys
sys.setrecursionlimit(100000)
def is_symmetric(s,i,j):
    if i>=j:
        return True
    if s[i]!=s[j]:
        return False
    return is_symmetric(s,i+1,j-1)
n = int(input())
s = input()
print("YES" if is_symmetric(s,0,n-1) else "NO")
 
PREVIOUS NEXT
Tagged: #check #symmetric #python
ADD COMMENT
Topic
Name
2+1 =