SHARE
TWEET

Untitled

a guest Oct 17th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. t = int(input())
  2. s = input()
  3. r = s[::-1]
  4. s *= 2
  5. i = 0
  6.  
  7. while i < len(s):
  8.     t = 0
  9.     while i < len(s) and s[i] == r[t]:
  10.         t += 1
  11.         i += 1
  12.         if t == len(r):
  13.             print(i - len(r))
  14.             exit()
  15.     i += 1
  16.  
  17. print(-1)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top