Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- count = 0
- vector = list(input())
- try:
- last = n - vector[::-1].index("R") - 1 # last red
- first = vector.index("W") # first white
- while first < last:
- vector[first], vector[last] = vector[last], vector[first]
- count += 1
- last = n - vector[::-1].index("R") - 1
- first = vector.index("W")
- print(count)
- except ValueError:
- print(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement