码迷,mamicode.com
首页 >  
搜索关键字:binary tree right si    ( 32903个结果
leetcode--Scramble String
Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation...
分类:其他好文   时间:2014-07-06 13:57:54    阅读次数:155
leetcode--Maximal Rectangle
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.public class Solution { public...
分类:其他好文   时间:2014-07-06 13:50:22    阅读次数:153
POJ 2309 BST 树状数组基本操作
DescriptionConsider an infinite full binary search tree (see the figure below), the numbers in the nodes are 1, 2, 3, .... In a subtree whose root nod...
分类:其他好文   时间:2014-07-06 13:23:06    阅读次数:229
[Leetcode][BST][Validate Binary Search Tree]
判断一颗树是不是二分查找树,非常经典基础的一个算法。我很久之前第一次做的时候,是先求出来了树的前序遍历的结果,然后判断这个数组排序后是否和排序前相同,还要判断重复虾米的,很纠结的一种做法。后来思考了一下怎么用递归的思路做,觉得应该根据定义返回两个子树的最大值和最小值,写了一会代码,发现好麻烦,不太对...
分类:其他好文   时间:2014-07-06 13:14:30    阅读次数:178
A. Xor-tree
题目意思:给一颗n个节点的树,每个节点有一个值要么是0要么是1,改变某个节点的值时,它的儿子不变,它儿子的儿子翻转,它儿子的儿子的儿子不变,如此类推。给定各个节点的目标值,求最少的翻转次数,使得达到要求。题解思路:贪心+Dfs判断当前节点的值,与目标值比较1.当前节点值由其上上一个节点值是否需要改变...
分类:其他好文   时间:2014-07-06 12:57:48    阅读次数:150
[Leetcode][BST][Convert Sorted Array to Binary Search Tree]
把一个排好序的vector转换为一颗二分查找树。很简单的题目,递归即可,保证边界不要出错。 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; ...
分类:其他好文   时间:2014-07-06 12:53:50    阅读次数:174
【剑指offer】Q6:重建二叉树
class BTNode: def __init__(self, val): self.left = None self.right = None self.val = val ''' @ construct tree by inorder & preorder ''' def constructByInPre(inorder, instart, inend, preorde...
分类:其他好文   时间:2014-07-06 00:34:00    阅读次数:234
[Leetcode][Tree][Path Sum]
很简单的一道题,判断和为sum的路径是否存在。结果WA了两次,一次是由于没有考虑清楚深搜停止的条件,另外一次是由于没有考虑到Path必须是从root到leaf的。 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * ...
分类:其他好文   时间:2014-07-05 22:39:11    阅读次数:253
[Leetcode][Tree][Sum Root to Leaf Numbers]
非常简单的一个题,和path sum非常类似。 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *rig...
分类:其他好文   时间:2014-07-05 22:03:48    阅读次数:251
解析java树形结构
思路一:1、准备表结构及对应的表数据a、表结构:create table TB_TREE(CID NUMBER not null,CNAME VARCHAR2(50),PID NUMBER //父节点)b、表数据:insert into tb_tree (CID, CNAME, PID) value...
分类:编程语言   时间:2014-07-05 20:54:07    阅读次数:396
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!