Google Interview QuestionJava Developers
- 0of 0 votes
Give the structure of a directed graph
START -> a -> b -> c -> END
If a word can start from start and end at END, then we think the word is in this diagram
For example, the string "abc" is consistent, but "ab" does not match,
Although "ab" is also inside the graph, b's next is "c" instead of END, so it's not legal word
(Note: each node can have more than one next)
1. According to the problem, design the data structure
Write a function, input is START and a string, to determine whether the string is a valid word
3. follow up, if the graph has cycle, how to do?
4. If the graph has repeated characters how to do?
Country: United States