码迷,mamicode.com
首页 >  
搜索关键字:binary    ( 11734个结果)
[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
1099. Build A Binary Search Tree (30)
题目要求: A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than the node's key....
分类:其他好文   时间:2015-03-31 14:46:43    阅读次数:168
二叉树的层序遍历
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
Treap
Treap         Treap是一种动态平衡的BST(Binary Search Tree),它每个节点拥有键值和优先级两种属性。对于键值而言,它是一颗排序二叉树。对于优先级而言,这棵树是堆(优先级最高的是根节点)。可以证明Treap中插入,删除和查找的期望时间复杂度均为O(logn)。关于Treap的更多介绍,可见刘汝佳《训练指南》P230。 一般我们用Treap就是用来替代平衡二叉...
分类:其他好文   时间:2015-03-31 14:40:38    阅读次数:226
leetcode || 50、Pow(x, n)
problem: Implement pow(x, n). Hide Tags  Math Binary Search 题意:求x的n次幂 thinking: (1)最简单想到的是直观上的数学幂函数求法,测试通过。算法时间复杂度为O(n) (2)按照标签提示,使用二分搜索法。pow(x,n) = po...
分类:其他好文   时间:2015-03-31 10:58:50    阅读次数:130
Add Binary
Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". #include #include #include using namespace std; string addBinary(string a, s...
分类:其他好文   时间:2015-03-31 10:56:04    阅读次数:105
03-树2. Tree Traversals Again (25)
03-树2. Tree Traversals Again (25)时间限制200 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, YueAn inorder binary tree traversal can be implemented in a non...
分类:其他好文   时间:2015-03-31 10:28:08    阅读次数:170
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!