Advertisement
Dimaush

Untitled

Jan 30th, 2023
837
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. n = int(input())
  2. s = input()
  3.  
  4. idx = 0
  5. right = 0
  6. left = 0
  7. total = 0
  8.  
  9. while idx < n:
  10.     while idx < n and s[idx] == '>':
  11.         right += 1
  12.         idx += 1
  13.     while idx < n and s[idx] == '<':
  14.         left += 1
  15.         idx += 1
  16.     total += right * left
  17.     left = 0
  18. print(total)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement