HTMLify
LeetCode - Number of Lines To Write String - Go
Views: 292 | Author: abh
1 2 3 4 5 6 7 8 9 10 11 12 13 | func numberOfLines(widths []int, s string) []int { var line, lw int line = 1 for _, c := range s { w := widths[c-97] if lw + w > 100 { line++ lw = 0 } lw += w } return []int{line, lw} } |