BFS -- O(V+E) Time O(V)space
用queue, define graph 里面的level概念。
» 133. Clone Graph(BFS) 各大家
level为current node's negihbors
http://rainykat.blogspot.com/2017/01/leetcode-133-clone-graphbfs.html
» 127. Word Ladder(BFS) 各大家
level focus on queue size.
http://rainykat.blogspot.com/2017/01/leetcode-127-word-ladderbfs.html
» 269. Alien Dictionary 各大家
level is defined before loop, add to queue when meeting requirements
http://rainykat.blogspot.com/2017/01/leetcode-269-alien-dictionarybfs.html
No comments:
Post a Comment