Answer the question
In order to leave comments, you need to log in
How to replace in a string those words that are possible with their synonyms?
Two strings s1 and s2 are given. The string s1 contains arbitrary text. Words in the text are separated by spaces and punctuation marks. String s2 contains no more than 30 words separated by commas. These words form pairs: each second is synonymous with the first. Replace in the string s1 those words that are possible with their synonyms.
Answer the question
In order to leave comments, you need to log in
You take the first word from s2, run through the first line, if you find a match, then assign to this match the next word from s2. Then we take the 3rd word from s2, and similarly run through the first line. I think the algorithm is clear.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question