Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def numberOfWays(self, corridor: str) -> int:
- res = 1
- cnt = 0
- temp = 1
- for i in corridor:
- if cnt == 2 and i == 'P':
- temp += 1
- elif cnt == 2 and i == 'S':
- res *= temp
- temp = 1
- cnt = 1
- else:
- cnt += int(i=='S')
- if cnt == 2:
- return res%int(1e9+7)
- return 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement