Generate Table of Contents

You are given a document as an array of strings. Your task is to generate a Table of Contents (TOC) based on simple markup rules.\n- A chapter is any line starting with # .\n- A section is any line ...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: