Algorithm · Google · Medium
Write a function count_lines(text, width) that returns the fewest lines necessary to hold every word from the input string text, subject to a line length limit width. Lines are constructed according to these rules: A line may contain one or more words. Between words you must place exactly one space. The total number of characters on a given line (including the required single spaces) must not exceed width, unless a single word is longer than width. In that exceptional case,…
Checking your access…