Imagine you're designing a text editor that needs to wrap text across multiple lines based on pixel width rather than character count! ๐
You have a string s containing only lowercase English letters and an array widths where each element represents the pixel width of a letter. Specifically, widths[0] is the width of 'a', widths[1] is the width of 'b', and so on.
Your task is to write the string across multiple lines where each line can be at most 100 pixels wide. Start from the beginning of the string and pack as many characters as possible on each line without exceeding the 100-pixel limit.
Goal: Return an array of length 2 where:
โข result[0] = total number of lines needed
โข result[1] = width of the last line in pixels
For example, if writing "abc" with widths [4, 6, 8] and each character fits on one line, you'd need 1 line with total width 18 pixels.
Input & Output
Constraints
- widths.length == 26
- 2 โค widths[i] โค 10
- 1 โค s.length โค 1000
- s contains only lowercase English letters