The string corridor describes a row of seats (S) and plants (P). Its two ends are already closed by dividers. You may add at most one divider in any gap between adjacent characters. Count the ways to partition the entire row so that every section contains exactly two seats and any number of plants. Different sets of divider positions count as different ways. Return the count modulo 1000000007, or 0 if no valid partition exists.
Dashed lines mark possible divider positions between groups of two seats; choose one divider in each such gap.
Example 1:
Input: corridor = "SSPSS"
Output: 2Explanation: The two valid partitions are SS | PSS and SSP | SS. Each section has exactly two seats.
Example 2:
Input: corridor = "PSSP"
Output: 1Explanation: There are exactly two seats in the entire corridor, so the only valid choice is to add no divider.
Example 3:
Input: corridor = "SSS"
Output: 0Explanation: There are three seats. Sections of exactly two seats cannot cover an odd number of seats, so no partition is valid.
Constraints:
1 <= corridor.length <= 100000- Every character is
SorP.