Question 21 || Hacker Rank
Querying the Document || Hacker Rank
A report is
addressed as an assortment passage, a section is addressed as an assortment of
sentences, a sentence is addressed as an assortment of words and a word is
addressed as an assortment of lower-case ([a-z]) and capitalized ([A-Z])
English characters.
You will
change over a crude message report into its part sections, sentences and words.
To test your outcomes, questions will request that you return a particular
section, sentence or word as portrayed beneath.
Alicia is
concentrating on the C programming language at the College of Dunkirk and she
addresses the words, sentences, sections, and archives utilizing pointers:
· A word is portrayed by char*.
· A sentence is portrayed by char**.
The words in the sentence are isolated by one space (" "). The final
word doesn't end with a space (" ").
· A section is portrayed by char***.
The sentences in the section are isolated by one period (".").
· A report is depicted by char****.
The passages in the report are isolated by one newline("\n"). The
last passage doesn't end with a newline.
For instance:
Learning C is fun.
Learning pointers is more fun. It is good to have
pointers.
· The main sentence in the principal
passage could be addressed as:
char** first_sentence_in_first_paragraph =
{"Learning", "C", "is", "fun"};
· The primary passage itself could be
addressed as:
char*** first_paragraph = {{"Learning",
"C", "is", "fun"}};
· The main sentence in the subsequent
section could be addressed as:
char** first_sentence_in_second_paragraph =
{"Learning", "pointers", "is", "more",
"fun"};
· The second sentence in the subsequent
passage could be addressed as:
char** second_sentence_in_second_paragraph =
{"It", "is", "great", "to",
"have", "pointers"};
· The subsequent passage could be
addressed as:
char*** second_paragraph = {{"Learning",
"pointers", "is", "more", "fun"},
{"It", "is", "great", "to",
"have", "pointers"}};
· At last, the record could be
addressed as:
char**** record = {{{"Learning",
"C", "is", "fun"}}, {{"Learning",
"pointers", "is", "more", "fun"},
{"It", "is", "great", "to",
"have", "pointers"}}};
Alicia has
sent a record to her companion Teodora as a series of characters, for example
addressed by char* not char****.
Help her proselyte the report to char**** shape by finishing the
accompanying capabilities:
- · char**** get_document(char* text)
to return the document represented by char****.
- ·
char*** kth_paragrapgh(char**** document, int k)
to return the kth paragraph.
- · char* kth_word_in_mth_sentence_of_nth_paragrapgh(char**** document, int
k, int m, int n)
To return the kth word
in the mth sentence of the nth paragrapgh.
Input
Organization
The primary
line contains the whole number paragrapgh_count.
Every one of
the following lines contains a section as a solitary string.
The
following line contains the number paragrapgh_count, the quantity
of inquiries.
Every one of
the following lines or gatherings of lines contains a question in one of the
accompanying configurations:
· 1) The main line contains 1 k:
o
The
following line contains a number x, the quantity of sentences in the kth
passage.
o
Every
one of the following x lines contains a number a[i], the
quantity of words in the kthsentence.
o
This
question compares to calling the capability kth_paragraph.
· 2) The primary line contains 2 k m:
o
The
following line contains a whole number x, the quantity of words in the
sentence of the kth passage to the mth.
o This question compares to calling the
capability called kth_sentence_in_mth_paragraph.
· 3) The main line contains 3 k m:
o
This
question relates to calling the capability
Imperatives
kth_word_on_mth_sentence_of_nth_paragrapgh.
Constraints:
· The message which is passed to the get_document
has words isolated by a space (" "), sentences isolated by a
period (".") and passages isolated by a newline("\n").
· The final say regarding a sentence
doesn't end with a space.
· The last passage doesn't end with a
newline.
· The words contain just capitalized
and lower-case English letters.
· 1 <= number of characters in the whole
report <= 1000
· 1 <= number of passages in the whole
archive <= 5
Yield
Arrangement
Print the
section, sentence or the word comparing to the question to actually look at the
rationale of your code.
Test Info
0
2
Learning C is fun.
Learning pointers is more fun.It is good to have pointers.
3
1 2
2
5
6
2 1 1
4
3 1 1 1
Test
Result 0
Learning pointers is more fun.It is good to have pointers.
Learning C
is fun.
Learning
Clarification
0
The primary inquiry relates to returning the second section with 2 sentences of lengths 5 and 6 words.
The
subsequent question compare to returning the principal sentence of the primary
section. It contains 4 words.
The third
question relates to returning the main expression of the primary sentence of
the principal section.
0 Comments