Advertisement
-fury

Codechef_3

Oct 20th, 2021
848
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. t=int(input(''))
  2. for i in range(t):
  3.     x=int(input(''))
  4.     a=input('')
  5.     w=[]
  6.     for i in range(0,x-2):
  7.         for j in range(i,x+1):
  8.             w.append(a[i:j])
  9.     for i in w:
  10.         q=0
  11.         for j in i:
  12.             if j=='L':
  13.                 q+=1
  14.             else:
  15.                 q-=1
  16.         if abs(q)%2==0 and q!=0:
  17.             print('YES')
  18.             break
  19.         else:
  20.             pass
  21.     else:
  22.         print('NO')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement