You are given a string s of lowercase English letters and an array widths denoting how many pixels wide each lowercase English letter is. Specifically, widths[0] is the width of 'a', widths[1] is the width of 'b', and so on.

You are trying to write s across several lines, where each line is no longer than 100 pixels. Starting at the beginning of s, write as many letters on the first line such that the total width does not exceed 100 pixels. Then, from where you stopped in s, continue writing as many letters as you can on the second line. Continue this process until you have written all of s.

Return an array result of length 2 where:


	result[0] is the total number of lines.
	result[1] is the width of the last line in pixels.


&nbsp;
Example 1:

Input: widths = [10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10], s = "abcdefghijklmnopqrstuvwxyz"
Output: [3,60]
Explanation: You can write s as follows:
abcdefghij  // 100 pixels wide
klmnopqrst  // 100 pixels wide
uvwxyz      // 60 pixels wide
There are a total of 3 lines, and the last line is 60 pixels wide.

Example 2:

Input: widths = [4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10], s = "bbbcccdddaaa"
Output: [2,4]
Explanation: You can write s as follows:
bbbcccdddaa  // 98 pixels wide
a            // 4 pixels wide
There are a total of 2 lines, and the last line is 4 pixels wide.

&nbsp;
Constraints:


	widths.length == 26
	2 &lt;= widths[i] &lt;= 10
	1 &lt;= s.length &lt;= 1000
	s contains only lowercase English letters.


class Solution:
    def numberOfLines(self, w: List[int], s: str) -> List[int]:
        r=[0]*2
        px=0
        l=1
        for i in range(len(s)):
            px+=w[ord(s[i])-97]
            if px>100:
                l+=1
                px=w[ord(s[i])-97]
                
            print(ord(s[i]))
        r[0]=l
        r[1]=px
        return r
        
class Solution {
    public int[] numberOfLines(int[] widths, String s) {
            int sum=0,count=0;
            for(int j=0;j<s.length();j++)
            {
                int pos = s.charAt(j)-'a';
                sum+=widths[pos];
                if(sum>100)
                {
                    j--;
                    count++;
                    sum=0;
                    continue;
                }
            }
        int[] arr = new int[2];
        arr[0]=count+1;
        arr[1]=sum;
        return arr;
    }
}
class Solution {
public:
    vector<int> numberOfLines(vector<int>& widths, string s) {
        vector<int>ans(2);
        int lines =0;
        int calc = 0;
        int i =0;
        while(i<s.length()){
            calc = 0;
            while(i<s.length() and calc<=100){
                calc+=widths[s[i]-'a'];
                i++;
            }
            if(calc>100){
                i-=1;
                calc-=widths[s[i]-'a'];
            }
            lines++;
            // cout<<lines;
        }
        ans[0] = lines;
        ans[1] = calc;
        return ans;
    }
};
var numberOfLines = function(widths, s) {
    let pixel=100, line=1;
    for(let i=0; i<s.length; i++){
        if(pixel>=widths[s[i].charCodeAt()-97]){
            pixel-=widths[s[i].charCodeAt()-97];
        }else{
            // this word should be written in NEXT line, so it CANNOT count.
            i--; line++; pixel=100;
        }
    }
    // 100-pixel = space used in this line.
    return [line, 100-pixel];
};
Number of Lines To Write String