forked from fredfeng0326/LeetCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlet806.py
More file actions
21 lines (20 loc) · 673 Bytes
/
let806.py
File metadata and controls
21 lines (20 loc) · 673 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 806. Number of Lines To Write String
class Solution:
def numberOfLines(self, widths, S):
"""
:type widths: List[int]
:type S: str
:rtype: List[int]
"""
line_words = 0
lines = 1
for word in S:
word_length = widths[ord(word)-97]
line_words = word_length + line_words
if line_words > 100:
line_words = word_length
lines +=1
print (line_words)
return [lines,line_words]
a = Solution()
print (a.numberOfLines([10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10],'abcdefghijklmnopqrstuvwxyz'))