Number of Lines To Write String LeetCode solution in Python

1
class Solution:
2
def numberOfLines(self, w: List[int], s: str) -> List[int]:
3
r = [0] * 2
4
px = 0
5
l = 1
6
for i in range(len(s)):
7
px += w[ord(s[i]) - 97]
8
if px > 100:
9
l += 1
10
px = w[ord(s[i]) - 97]
11

12
print(ord(s[i]))
13
r[0] = l
14
r[1] = px
15
return r

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0