You are given a string sentence containing words separated by single spaces, and an integer k.
You need to split sentence into multiple rows such that:
The words in each row remain in their original order.
The words within each row are separated by a single space.
The total length of any row does not exceed k.
The cost of each row with length
Return the minimum total cost to divide sentence into rows.
Constraints:
sentence.length
k
The length of each word in sentence is at most k.
sentence consists of only lowercase English letters and spaces.
sentence does not begin or end with a space.
Words in sentence are separated by a single space.
You are given a string sentence containing words separated by single spaces, and an integer k.
You need to split sentence into multiple rows such that:
The words in each row remain in their original order.
The words within each row are separated by a single space.
The total length of any row does not exceed k.
The cost of each row with length
Return the minimum total cost to divide sentence into rows.
Constraints:
sentence.length
k
The length of each word in sentence is at most k.
sentence consists of only lowercase English letters and spaces.
sentence does not begin or end with a space.
Words in sentence are separated by a single space.