Leetcode 806. Number of Lines To Write String
Given an array widths mapping each lowercase letter to its pixel width and a string s, pack characters sequentially into lines with a maximum width of 100 pixels and return [number_of_lines, width_of_last_line]. This is solved by greedily scanning s, accumulating letter widths and starting a new line whenever adding the next letter would exceed 100.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Mid March, 2026
a mix of 806 and text justification. "You work at a publisher house and are going to print the number of lines of a large file given it's input path, count the number of lines in the file." No examples were provided. As a sub-problem you have to first suggest that the page width would be a parameter, then return number of lines.
Mid October, 2024
Given a sequence of words as a single string, place them into lines of specified width. Return the number of lines needed.
Hello Interview Premium
Your account is free and you can post anonymously if you choose.