Google Interview Question for Software Developers
- -3of 3 votes
AnswersModify the following code:
def GenerateGraph(data): d = {} g = Graph() for word in data: for i in range(len(word)): bucket = word[:i] + '_' + word[i+1:] if bucket in d: d[bucket].append(word) else: d[bucket] = [word] for v in d.keys(): for word1 in d[v]: for word2 in d[v]: if word1 != word2: g.addEdge(word1,word2) return g
The objective is to find all combination of words by changing one letter at a time and adding to the graph if word exists in the dictionary.
- newbiepython January 28, 2018 in United States
We need to rewrite a different logic for the above code.| Report Duplicate | Flag | PURGE
Google Software Developer Python
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.