Search
⌘K

Leetcode 2147. Number of Ways to Divide a Long Corridor

Count the ways to insert dividers between characters in a string of 'S' (seats) and 'P' (plants) so every resulting section contains exactly two 'S', returning the result modulo 1e9+7. The core challenge is checking the total number of seats is even and then computing the combinatorial choices determined by the plant gaps between consecutive seat-pairs.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Your account is free and you can post anonymously if you choose.