String Formation (Also for AI/ML Software Engineer Intern :)
Problem Overview
- Count ways to form a target string from equal-length words by choosing characters at strictly increasing indices; picks can be from any word, including multiple from one.
- Two ways differ if index sequences differ or if at any index the chosen word differs; return the count modulo 1e9+7.
- Input: words[n] (lowercase, same length) and target; Output: int. Constraints: n≤1e3, |word|≤3000, sum lengths≤1e5, |target|≤|word|.
- Real-world: string combinatorics for text processing; a Snowflake interviews coding interview problem and common interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
