Dsa
Dynamic Programming
Medium
Word Break Combination Count
Given a string s and a dictionary of words, find the number of different ways the string can be segmented into words from the dictionary.
Input Format:
- The first line contains the string s.
- The second line contains an integer n (the number of dictionary words).
- The next n lines contain each dictionary word.
Output Format:
- A single integer representing the number of ways to segment the string.
Example:
Input:
leetcode
2
leet
code
Output:
1
Key concepts
dynamic_programmingstringscombinatorics
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now