NeetCode #704LC-2147Hard1-D Dynamic Programming
← Back to All Problems#704 · #2147 · Number of Ways to Divide a Long Corridor(分隔长廊的方案数)
📌 Problem Statement & Constraints
Given a corridor string
corridor made of S (seat) and P (plant), place dividers on plants to split the corridor into sections that each contain exactly two seats. Count the number of ways, modulo 10^9 + 7. Constraints: 1 <= corridor.length <= 10^5, and corridor consists only of S and P.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!