problem

806. Number of Lines To Write String

solution:

class Solution {
public:
vector<int> numberOfLines(vector<int>& widths, string S) {
int line = , len = ;
for(auto ch:S)
{
int t = widths[ch-'a'];
if(len+t>) line++;
len = (len+t>) ? t : len+t;
}
return {line, len};
}
};

参考

1. Leetcode_easy_806. Number of Lines To Write String;

2. Grandyang;

【Leetcode_easy】806. Number of Lines To Write String的更多相关文章

  1. 【LeetCode】806. Number of Lines To Write String 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 使用ASIIC码求长度 使用字典保存长度 日期 题目 ...

  2. 806. Number of Lines To Write String

    806. Number of Lines To Write String 整体思路: 先得到一个res = {a : 80 , b : 10, c : 20.....的key-value对象}(目的是 ...

  3. 806. Number of Lines To Write String - LeetCode

    Question 806. Number of Lines To Write String Solution 思路:注意一点,如果a长度为4,当前行已经用了98个单元,要另起一行. Java实现: p ...

  4. 【LeetCode】434. Number of Segments in a String

    Count the number of segments in a string, where a segment is defined to be a contiguous sequence of ...

  5. 【LeetCode】434. Number of Segments in a String 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 统计 正则表达式 字符串分割 日期 题目地址:htt ...

  6. 【Leetcode_easy】933. Number of Recent Calls

    problem 933. Number of Recent Calls 参考 1. Leetcode_easy_933. Number of Recent Calls; 完

  7. 【Leetcode_easy】1128. Number of Equivalent Domino Pairs

    problem 1128. Number of Equivalent Domino Pairs solution1: 不明白为什么每个元素都要加上count: class Solution { pub ...

  8. LeetCode 806 Number of Lines To Write String 解题报告

    题目要求 We are to write the letters of a given string S, from left to right into lines. Each line has m ...

  9. [LeetCode&Python] Problem 806. Number of Lines To Write String

    We are to write the letters of a given string S, from left to right into lines. Each line has maximu ...

随机推荐

  1. git将一个分支的内容替换为另一分支内容

    假设我想将我的linux分支内容替换master分支的内容. # 切换到master分支 git checkout master # 再将本地的master分支重置成linux git reset - ...

  2. git 和 svn比较

    SVN和Git 介绍,区别,优缺点,适用范围总结 原创 2016年01月29日 15:17:36 15774   介绍   SVN SVN是Subversion的简称,是一个开放源代码的版本控制系统, ...

  3. socket.gaierror: [Errno 11001] getaddrinfo failed

  4. Python pip 虚拟环境使用

    安装: pip install virtualenv 使用,创建虚拟环境: cd project_dir virtualenv venv #venv为虚拟环境 目录名自定义 virtualenv -p ...

  5. Debian 9.x "stretch" 解决 /etc/rc.local 开机启动问题

    由于某些软件并没有增加开启启动的服务,很多时候需要手工添加,一般我们都是推荐添加命令到 /etc/rc.local 文件,但是 Debian 9 默认不带 /etc/rc.local 文件,而 rc. ...

  6. PostgreSQL 学习手册-模式Schema

    一个数据库包含一个或多个命名的模式,模式又包含表.模式还包含其它命名的对象,包括数据类型.函数,以及操作符.同一个对象名可以在不同的模式里使用而不会导致冲突: 比如,schema1和myschema都 ...

  7. MySQL 优化--持续整理

    一.innodb体系结构优化: 1.IO优化 IO能力不足时 innodb_io_capacity 应该降低 innodb_max_dirty_pages_pct 应该降低 innodb_max_di ...

  8. learning scala extractor object

    package com.aura.scala.day01 import scala.util.Random object extractorObject { def main(args: Array[ ...

  9. 模拟I2C协议学习点滴之复习三极管、场效应管

    晶体三极管分为NPN和PNP型两种结构形式,除了电源极性的不同工作原理是大致相同的.对于NPN管,它是由2块N型半导体夹着一块P型半导体所组成的,发射区与基区之间形成的PN结称为发射结,而集电区与基区 ...

  10. firewalld命令集--firewall-cmd

    Linux上新用的防火墙软件,跟iptables差不多的工具 补充说明 firewall-cmd 是 firewalld的字符界面管理工具,firewalld是centos7的一大特性,最大的好处有两 ...