码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
Binary Tree Preorder Traversal
二叉树的前序遍历 思路:小心程序运行栈溢出,用stack模拟 class Solution {public: vector preorderTraversal(TreeNode *root) { stack stk; vector res; if (root) stk.push(root); els...
分类:其他好文   时间:2015-04-01 11:10:06    阅读次数:134
关于erlang的binary
引自:http://cryolite.iteye.com/blog/15472521. binary数据是可以在不同进程间共享的 当然这些进程都在同一Erlang节点上。这与普通term不同,后者作为消息在进程间传递时是要在接收进程中做拷贝的(当然atom数据例外,它们也不会做拷贝)。摘一段原文在这...
分类:其他好文   时间:2015-04-01 10:52:40    阅读次数:126
HDOJ 题目1710 Binary Tree Traversals(二叉搜索树)
Binary Tree Traversals Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3912    Accepted Submission(s): 1741 Problem Description A b...
分类:其他好文   时间:2015-04-01 09:41:27    阅读次数:209
【leetcode刷题笔记】Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.题解:递归就可以了。Java代码如下: 1 /** 2 * Definition for binary ....
分类:其他好文   时间:2015-04-01 00:16:07    阅读次数:96
LeetCode Add Binary
Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 题意:二进制的加法。 思路:跟大数加法差不多。 class Solution { public: string addBinary(string a, ...
分类:其他好文   时间:2015-03-31 22:25:38    阅读次数:160
[LeetCode] Maximal Rectangle
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. 解题思路; 题意表示找到右全1形成的最大的矩形块。 解法1: 用动态规划做,若d[i][j]表示以matrix[...
分类:其他好文   时间:2015-03-31 22:15:43    阅读次数:159
Unique Binary Search Trees -- LeetCode
原题链接:http://oj.leetcode.com/problems/unique-binary-search-trees/这道题要求可行的二叉查找树的数量,事实上二叉查找树能够随意取根,仅仅要满足中序遍历有序的要求就能够。从处理子问题的角度来看,选取一个结点为根,就把结点切成左右子树,以这个结...
分类:其他好文   时间:2015-03-31 21:39:33    阅读次数:84
LeetCode OJ 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. 之前在Sicily做过,就是实现一个AVL树了。 struct TreeNodeNew { int val; TreeNodeNew *left; Tr...
分类:其他好文   时间:2015-03-31 18:09:23    阅读次数:150
LeetCode OJ Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example: Given the below binary tree, 1 / 2 3 Return 6. i...
分类:其他好文   时间:2015-03-31 18:01:18    阅读次数:119
二叉树的层序遍历
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree {3,9,20,#,#,15,7}, 3 / 9 20 ...
分类:其他好文   时间:2015-03-31 14:46:03    阅读次数:146
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!