Number of Lines To Write String
<-E 806> Number of Lines To Write String
class Solution {
public:
vector<int> numberOfLines(vector<int>& widths, string S) {
int W = 0, L = 1;
for(auto i:S) {
W += widths[i - 'a'];
if(100 < W) {
W = widths[i - 'a'];
L++;
}
}
return {L, W};
}
};