Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Divide a Long Corridor

med
30 min
Try to solve the Number of Ways to Divide a Long Corridor problem.

Statement

You are given a string corridor of length n representing a corridor layout, where each character is either 'S' representing a seat or 'P' representing a plant.

You want to install dividers to divide the corridor into adjacent sections such that each section contains exactly 22 seats and any number of plants. Dividers can only be placed between adjacent positions in the corridor. Two ways of dividing the corridor are considered different if there is a position with a divider in one way and not in the other.

Return the number of ways to divide the corridor. Since the answer may be large, return it modulo 109+710^9 + 7. If there is no valid way to divide the corridor, return 00.

Constraints:

  • n == corridor.length

  • 1≤n≤1051 \leq n \leq 10^5

  • corridor[i] is either 'S' or 'P'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Divide a Long Corridor

med
30 min
Try to solve the Number of Ways to Divide a Long Corridor problem.

Statement

You are given a string corridor of length n representing a corridor layout, where each character is either 'S' representing a seat or 'P' representing a plant.

You want to install dividers to divide the corridor into adjacent sections such that each section contains exactly 22 seats and any number of plants. Dividers can only be placed between adjacent positions in the corridor. Two ways of dividing the corridor are considered different if there is a position with a divider in one way and not in the other.

Return the number of ways to divide the corridor. Since the answer may be large, return it modulo 109+710^9 + 7. If there is no valid way to divide the corridor, return 00.

Constraints:

  • n == corridor.length

  • 1≤n≤1051 \leq n \leq 10^5

  • corridor[i] is either 'S' or 'P'.