就是个简单的计数问题:
class Solution {
public int[] numberOfLines(int[] widths, String S) {
char[] s = S.toCharArray();
int count = 0,countline = 0;
for(int i=0;i<s.length;i++){
count += widths[s[i]-'a'];
if(count>100){
countline++;
count = widths[s[i]-'a'];
}
}
return new int[]{countline+1,count};
}
}