first and second. There is also a synonym dictionary synonyms: each pair [x, y] says that x and y are synonyms.
Being synonyms works both ways and carries along a chain: if a is a synonym of b and b is a synonym of c, then a and c are synonyms too. Every word is a synonym of itself.
The phrases **mean the same** when they have the same number of words and, for every position i, the words first[i] and second[i] are synonyms. Return True if so, otherwise False.first=["a", "quick", "trip"], second=["a", "rapid", "journey"], synonyms=[["quick", "fast"], ["rapid", "fast"], ["trip", "journey"]] → True
"a" matches itself, quick → fast → rapid are linked by a chain, and trip and journey are direct synonyms.
first=["big", "house"], second=["large", "home"], synonyms=[["big", "large"], ["home", "flat"]] → False
No chain of synonyms connects house and home.
first=["hi"], second=["hi", "there"], synonyms=[] → False
The word counts differ, so the phrases cannot match.
first=["a", "quick", "trip"], second=["a", "rapid", "journey"], synonyms=[["quick", "fast"], ["rapid", "fast"], ["trip", "journey"]]
True
Run checks the first 3 tests in your browser. Submit checks all 111 tests on the server, hidden ones included.