Graphs and String Manipulation - Medium LC
This problem is just laborious but requires a bit of work on Graphs (I usually build the graphs using Hashtables), traversal of graphs (in this case DFS) and string manipulation. Interesting that the standard String.CompareTo C# does not really compare lexicographically, at least when I used it, it failed for some test cases, so I had to build my own. Long code is down below, cheers, ACC. Synonymous Sentences - LeetCode 1258. Synonymous Sentences Medium 195 75 Add to List Share You are given a list of equivalent string pairs synonyms where synonyms[i] = [s i , t i ] indicates that s i and t i are equivalent strings. You are also given a sentence text . Return all possible synonymous sentences sorted lexicographically . Example 1: Input: synonyms = [["happy","joy"],["sad","sorrow"],["joy","cheerful"]], text = "I am happy today but was sad yesterday" Output: ["I am cheerful today but was sad yester...