葉林
Linked with GitHub
# LeetCode - 0806. Number of Lines To Write String ### 題目網址:https://leetcode.com/problems/number-of-lines-to-write-string/ ###### tags: `LeetCode` `Easy` `模擬` ```cpp= /* -LeetCode format- Problem: 806. Number of Lines To Write String Difficulty: Easy by Inversionpeter */ class Solution { public: vector<int> numberOfLines(vector<int>& widths, string s) { int nowLineLength = 0, lines = 1; for (int i = 0; i != s.size(); ++i) { if (nowLineLength + widths[s[i] - 'a'] > 100) nowLineLength = 0, ++lines; nowLineLength += widths[s[i] - 'a']; } return { lines, nowLineLength }; } }; ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up