Ezvor

2052. Minimum Cost to Separate Sentence Into Rows

MediumString Preparing judge… LeetCode
StringDynamic Programming

Hints

Hint 1
Create an array storing all of the words in sentence separated.
Hint 2
Try dynamic programming.
Hint 3
Build a dp array where dp[i] represents the minimum total cost for the first i + 1 words.