Skip to content

Instantly share code, notes, and snippets.

@prkagrawal
Last active June 20, 2020 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prkagrawal/388eb6630a4bbd5e45fe5cedd764c9f3 to your computer and use it in GitHub Desktop.
Save prkagrawal/388eb6630a4bbd5e45fe5cedd764c9f3 to your computer and use it in GitHub Desktop.
n,t = map(int,input().split())
s = str(input())
l = list(s)
z = len(s) - 1
for i in range(t):
for a in range(z):
if l[a]=='B' and l[a+1]=='G':
l[a] = 'G'
l[a+1] = 'B'
a = a + 1
s = ''.join(l)
print(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment