We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e36caa1 commit 98ae5b6Copy full SHA for 98ae5b6
scripts/algorithms/N/Number of Lines To Write String/Number of Lines To Write String.js
@@ -1,13 +1,14 @@
1
+// Runtime: 110 ms (Top 27.73%) | Memory: 43.1 MB (Top 24.37%)
2
var numberOfLines = function(widths, s) {
3
let pixel=100, line=1;
4
for(let i=0; i<s.length; i++){
5
if(pixel>=widths[s[i].charCodeAt()-97]){
6
pixel-=widths[s[i].charCodeAt()-97];
7
}else{
- // 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.
9
i--; line++; pixel=100;
10
}
11
- // 100-pixel = space used in this line.
12
+ // 100-pixel = space used in this line.
13
return [line, 100-pixel];
-};
14
+};
0 commit comments