problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::number_of_lines_to_write_string::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static vector< int > numberOfLines (vector< int > &widths, string s)
 

详细描述

在文件 leetcode.h2201 行定义.

成员函数说明

◆ numberOfLines()

vector< int > leetcode::number_of_lines_to_write_string::Solution::numberOfLines ( vector< int > &  widths,
string  s 
)
static

在文件 leetcode.cpp5914 行定义.

5914 {
5915 int lines = 1;
5916 int current = 0;
5917 for(int i = 0; i < s.length(); i++) {
5918 if(current + widths[s[i] - 'a'] > 100) {
5919 current = 0;
5920 lines++;
5921 }
5922 current += widths[s[i] - 'a'];
5923 }
5924 return {lines, current};
5925 }

被这些函数引用 leetcode::number_of_lines_to_write_string::TEST().


该类的文档由以下文件生成: