首页 > 其他 > 详细

806. Number of Lines To Write String

时间:2018-06-14 13:53:45      阅读:168      评论:0      收藏:0      [点我收藏+]
 1 static int wing=[]()
 2 {
 3     std::ios::sync_with_stdio(false);
 4     cin.tie(NULL);
 5     return 0;
 6 }();
 7 
 8 class Solution 
 9 {
10 public:
11     vector<int> numberOfLines(vector<int>& widths, string S) 
12     {
13         int count=1,length=0;
14         for(char c:S)
15         {
16             int cur=widths[c-a];
17             if(cur+length<100)
18             {
19                 length+=cur;
20                 continue;
21             }
22             else if(cur+length==100)
23             {
24                 count++;
25                 length=0;
26             }
27             else
28             {
29                 count++;
30                 length=cur;
31             }
32         }
33         return {count,length};
34     }
35 };

直接扫描,统计长度就行,问题不大

806. Number of Lines To Write String

原文:https://www.cnblogs.com/zhuangbijingdeboke/p/9182132.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!