Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- a = input()
- rev_a = a[::-1]
- flag = False
- count = 0
- for j in range(n):
- temp_a = a
- temp_a += a[:j]
- temp_a = temp_a[j:]
- count+=1
- if temp_a == rev_a:
- flag = True
- break
- if not(flag):
- print(-1)
- else:
- print(count-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement