I came across a question.
There is a sentence (say contains millions of words) and words are repetitive (e.g. Sentence is: "my name is ram, my name is shyam, ram is an engineer, shyam is also an engineer" and so on).

Goal is:

1. Memory should be efficiently used (word should be stored only once)
2. The sentence must be re-construct-able from the data structure.

Can someone suggest what data structure should be best suitable for this requirement.