Skip to content

Commit 98ae5b6

Browse files
committed
Runtime: 110 ms (Top 27.73%) | Memory: 43.1 MB (Top 24.37%)
1 parent e36caa1 commit 98ae5b6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
// Runtime: 110 ms (Top 27.73%) | Memory: 43.1 MB (Top 24.37%)
12
var numberOfLines = function(widths, s) {
23
let pixel=100, line=1;
34
for(let i=0; i<s.length; i++){
45
if(pixel>=widths[s[i].charCodeAt()-97]){
56
pixel-=widths[s[i].charCodeAt()-97];
67
}else{
7-
// this word should be written in NEXT line, so it CANNOT count.
8+
// this word should be written in NEXT line, so it CANNOT count.
89
i--; line++; pixel=100;
910
}
1011
}
11-
// 100-pixel = space used in this line.
12+
// 100-pixel = space used in this line.
1213
return [line, 100-pixel];
13-
};
14+
};

0 commit comments

Comments
 (0)