I have an string array filled with words from a sentence.
words[0] = \"the\"
words[1] = \"dog\"
words[2] = \"jumped\"
words[3] = \"over\"
words[4] = \"the\"
word
You may also use unordered_map
which has some benefit over map structure. You can do such insertion if your dictionary is like 'c': "cat"
, 'c':"car"
, 'a':apple
, 'a':"angus"
:
unordered_map> char_to_strings_map;
//loop to traverse the dictionary : key:c, value:s
char_to_strings_map[c].emplace_back(s);
//loop ends