-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtes.py
More file actions
24 lines (21 loc) · 666 Bytes
/
tes.py
File metadata and controls
24 lines (21 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def slv():
T = int(input().strip())
for _ in range(T):
commands = list(input().strip())
question_R = 0
question_L = 0
pos_R = []
pos_L = []
for command in commands:
if command == "?":
question_R += 1
question_L -= 1
else:
question_R += 1 if command == 'R' else -1
question_L += 1 if command == 'R' else -1
pos_R.append(question_R)
pos_L.append(question_L)
result = max(max([abs(i) for i in pos_R]), max([abs(i) for i in pos_L]))
print(result)
if __name__ == "__main__":
slv()