码迷,mamicode.com
首页 >  
搜索关键字:binary    ( 11734个结果)
Maximum Depth of Binary Tree
求一棵树的最大深度 思路:广度优先搜索即可 class Solution {public: int maxDepth(TreeNode *root) { int depth = 0; if (!root) return depth; queue nodeQue; nodeQue.push(root)...
分类:其他好文   时间:2015-04-11 11:38:05    阅读次数:117
Leetcode: Binary Tree Right Side View
Given 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 exam...
分类:其他好文   时间:2015-04-11 07:49:20    阅读次数:107
Populating Next Right Pointers in Each Node--LeetCode
题目: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right n...
分类:其他好文   时间:2015-04-11 00:07:02    阅读次数:170
[LeetCode] Binary Search Tree Iterator
Binary Search Tree Iterator Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the next smallest...
分类:其他好文   时间:2015-04-11 00:03:47    阅读次数:200
Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.用空间换时间的方法,先用一个数组将节点按序存放,然后建树,代码如下:/** * D...
分类:其他好文   时间:2015-04-10 21:51:05    阅读次数:117
[LeetCode] Populating Next Right Pointers in Each Node II
Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil...
分类:其他好文   时间:2015-04-10 19:33:42    阅读次数:102
[LeetCode] Populating Next Right Pointers in Each Node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe...
分类:其他好文   时间:2015-04-10 17:25:22    阅读次数:110
leetcode——Binary Tree Preorder Traversal(递归,栈的使用)
Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Not...
分类:其他好文   时间:2015-04-10 16:56:27    阅读次数:117
Full Binary Tree(GCJ2014 round1A PB)
去年google code jam第一轮的B题,我没有想明白,也没有找到题解。没有办法,就去下载了大神的代码来看看。感觉差距好大,别人用十分钟不到就做出来了。题目的描述如下,我就不写翻译了,题意挺明了的。由于墙的原因,我还是把题目贴下面吧!题目内容 A tree is a connected graph with no cycles.A rooted tree is a tree in which...
分类:其他好文   时间:2015-04-10 15:39:41    阅读次数:218
[LeetCode] Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum =...
分类:其他好文   时间:2015-04-10 15:14:35    阅读次数:125
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!