标签:source solution ring ack str nes ber res span
解答
class Solution {
public:
vector<int> numberOfLines(vector<int>& widths, string S) {
vector<int> result;
int line=1,units=0;
map<char,int> pairs;
char c=‘a‘;
for(int width:widths){
pairs.insert(make_pair(c,width));
++c;
}
for(auto ch: S){
units += pairs[ch];
if(units > 100){
++line;
units=pairs[ch];
}
}
result.push_back(line);
result.push_back(units);
return result;
}
};
806. Number of Lines To Write String (5月24日)
标签:source solution ring ack str nes ber res span
原文地址:https://www.cnblogs.com/cs-niaocai/p/9085726.html