Algorithm · JPMorgan · Easy
Requirements Input: lines, a string array in which each item represents one line from a document. Any line whose first characters are exactly one # (not ##) denotes a chapter. A line beginning with exactly two # characters (not ###) denotes a section associated with the latest chapter encountered. Disregard every line that does not match either heading form. Return an ordered collection of numbered table-of-contents items: chapters use forms such as "1. Title", "2. Title",…
Checking your access…