Number of Ways to Divide a Long Corridor LeetCode solution in Python
1class Solution:2def numberOfWays(self, corridor):3seat, res, plant = 0, 1, 04for i in corridor:5if i == "S":6seat += 17else:8if seat == 2:9plant += 110if seat == 3:11res = res * (plant + 1) % (10**9 + 7)12seat, plant = 1, 013if seat != 2:14return 015return res