码迷,mamicode.com
首页 >  
搜索关键字:binary    ( 11734个结果)
LeetCode Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.思路分析:这题比较简单,关于树的题目通常都可以用递归解决,这题也不例外,递归解法的思...
分类:其他好文   时间:2015-03-19 06:23:34    阅读次数:126
LeetCode Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.思路分析:判断两个树是否相同,基本也...
分类:其他好文   时间:2015-03-19 06:23:30    阅读次数:95
LeetCode – Refresh – Convert Sorted List to Binary Search Tree
Similar to the sorted array. But we have to remember, the position of node not depends on the index. So we need do two more things:1. Ensure the point...
分类:其他好文   时间:2015-03-19 06:20:30    阅读次数:132
LeetCode – Refresh – Construct Binary Tree from Inorder and Preorder Traversal
Only different with preorder and postorder is that the root start from the beginning for preorder. 1 /** 2 * Definition for binary tree 3 * struct T.....
分类:其他好文   时间:2015-03-19 06:20:26    阅读次数:122
LeetCode – Refresh – Convert Sorted Array to Binary Search Tree
It is kind of binary search. Since this is a sorted array, we can treat it as inorder traversal. And we can define the root node for the Tree.So find ...
分类:其他好文   时间:2015-03-19 06:19:48    阅读次数:105
LeetCode – Refresh – Construct Binary Tree from Inorder and Postorder Traversal
For this problem just need to know the structure of two traversal.1. It is hard to find the root node in the inorder traversal but it is easy in posto...
分类:其他好文   时间:2015-03-19 06:19:44    阅读次数:119
Number of 1 Bits (求32位二进制数中1的)
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11' has binary representation 00000000000000000000000000001011, so the function should return...
分类:其他好文   时间:2015-03-18 18:06:47    阅读次数:92
Path Sum(二叉树路径和)
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo...
分类:其他好文   时间:2015-03-18 15:20:00    阅读次数:131
二叉树的非递归遍历(先序, 中序, 后序)
先序遍历:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), ...
分类:其他好文   时间:2015-03-18 13:48:17    阅读次数:124
LeetCode – Refresh – Binary Tree Zigzag Level Order Traversal
Made a stupid bug....... When reverse the vector, stop it at mid. Otherwise, it will swap back......Mark!!!!!!!! 1 /** 2 * Definition for binary tree....
分类:其他好文   时间:2015-03-18 10:23:29    阅读次数:120
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!