[Silver V] Title: ABB to BA (Easy), Time: 56 ms, Memory: 32412 KB -BaekjoonHub
This commit is contained in:
13
백준/Silver/32292. ABB to BA (Easy)/ABB to BA (Easy).py
Normal file
13
백준/Silver/32292. ABB to BA (Easy)/ABB to BA (Easy).py
Normal file
@@ -0,0 +1,13 @@
|
||||
t = int(input())
|
||||
for _ in range(t):
|
||||
n = int(input())
|
||||
s = list(input())
|
||||
i = 0
|
||||
while i <= len(s) - 3:
|
||||
if s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'B':
|
||||
s[i], s[i + 1] = 'B', 'A'
|
||||
s.pop(i + 2)
|
||||
i = max(i - 2, 0)
|
||||
else:
|
||||
i += 1
|
||||
print(''.join(s))
|
||||
47
백준/Silver/32292. ABB to BA (Easy)/README.md
Normal file
47
백준/Silver/32292. ABB to BA (Easy)/README.md
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user