Company: oracle_31july
Difficulty: medium
Table of Contents Problem Description Design a system to extract a Table of Contents (TOC) from a document written in a simple markup format. The TOC should be structured based on the following rules: 1. Chapter Titles: A line that begins with a single # followed by a space (# Title) represents a chapter. 2. Section Titles: A line that begins with a double ## followed by a space (## Title) represents a section within a chapter. The output should list chapter titles as top-level entries and section titles as indented sub-entries under their respective chapters. Note that each number is followed by a period and the last period is followed by 1 space. For example, if the input text is: # Algorithms This chapter covers the most basic algorithms. ## Sorting Quicksort is fast and widely used in practice Merge sort is a deterministic algorithm ## Searching DFS and BFS are widely used graph searching algorithms some variants of DFS are also used in game theory applications # Data structures Th