Problem Statement | |||||||||||||
You have a sentence written entirely in a single row. You would like to split it into several rows by replacing some of the spaces with "new row" indicators. Your goal is to minimize the width of the longest row in the resulting text ("new row" indicators do not count towards the width of a row). You may replace at most K spaces. You will be given a String sentence and an int K. Split the sentence using the procedure described above and return the width of the longest row. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | sentence will contain between 1 and 50 characters, inclusive. | ||||||||||||
- | sentence will consist of only letters ('a'-'z', 'A'-'Z') and spaces (' '). | ||||||||||||
- | Each space character in sentence will be between two letters. | ||||||||||||
- | K will be between 1 and 50, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|