bfs
文章平均质量分 80
liuchenjane
这个作者很懒,什么都没留下…
展开
-
116. Populating Next Right Pointers in Each Node
Given a binary treestruct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next;}Populate each next pointer to point to its next right node. If there is no next right node,转载 2016-10-09 08:55:27 · 252 阅读 · 0 评论 -
199. Binary Tree Right Side View
199. Binary Tree Right Side ViewGiven a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Gi原创 2016-10-21 16:28:01 · 268 阅读 · 0 评论 -
127. Word Ladder
127. Word LadderGiven two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence frombeginWord to endWord, such that:Only one letter转载 2016-11-05 12:13:55 · 452 阅读 · 0 评论 -
133. Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each n转载 2016-10-14 19:08:41 · 235 阅读 · 0 评论 -
图的广度优先搜索BFS(C++)
这里对链表的结构进行了改编:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ #include #include #i原创 2016-11-07 16:24:22 · 1876 阅读 · 1 评论 -
279. Perfect Squares
279. Perfect SquaresGiven a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 1转载 2016-11-14 21:35:09 · 438 阅读 · 0 评论 -
45. Jump Game II
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal i转载 2017-01-15 16:38:54 · 235 阅读 · 0 评论 -
515. Find Largest Element in Each Row
You need to find the largest value in each row of a binary tree.Example:Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9]You need to fi原创 2017-02-12 18:49:35 · 418 阅读 · 0 评论