Official
B - 最後の大根 / The Last Radish Editorial
by
B - 最後の大根 / The Last Radish Editorial
by
harurun4635
Editorial for printing
文字列のうち、もっとも右にある D を見つければよいです。
右から走査し、見つけた場合はそこで
breakする左から見て、見つけた場合常に更新する
などの方法があります。
実装例
n = int(input())
s = input()
ans = -1
for i in range(n):
if s[i] == "D":
ans = i + 1
print(ans)
posted:
last update: