Structuring the Document in C hackerrank solution

      
  #include <stdio.h>           
  #include <stdlib.h>
  #include <string.h>
  #include <assert.h>
  
  #define MAX_CHARACTERS 1005
  #define MAX_PARAGRAPHS 5
  
  struct word {
      char* data;
  };
  
  struct sentence {
      struct word* data;
      int word_count;  // denotes the number of words in a sentence
  };
  
  struct paragraph {
      struct sentence* data;
      int sentence_count;  // denotes the number of sentences in a paragraph
  };
  
  struct document {
      struct paragraph* data;
      int paragraph_count;  // denotes the number of paragraphs in a document
  };

First, we define the necessary structures: word, sentence, paragraph, and document.
Each structure represents a different component of the document hierarchy.
We also define two constants: MAX_CHARACTERS for the maximum number of characters in the document and MAX_PARAGRAPHS for the maximum number of paragraphs in the document.

  
  struct document get_document(char* text) {

  }
  

The get_document function takes a string text as input and returns a document structure.
This function is responsible for parsing the text and creating the appropriate nested structures to represent the document.

  
  struct word kth_word_in_mth_sentence_of_nth_paragraph(struct document Doc, int k, int m, int n) {

  }
  

The kth_word_in_mth_sentence_of_nth_paragraph function takes a document structure Doc along with the indices k, m, and n and returns the k-th word in the m-th sentence of the n-th paragraph. This function allows us to query a specific word in the document.

To solve the problem, you need to implement the above functions according to the problem statement. Since the implementation involves parsing the text and creating nested structures, it requires careful handling of string manipulation and memory allocation.