码迷,mamicode.com
首页 >  
搜索关键字:spoj balnum balanced    ( 1777个结果
SPOJ COT2 Count on a tree II(树上莫队)
题目链接:http://www.spoj.com/problems/COT2/You are given a tree withNnodes.The tree nodes are numbered from1toN.Each node has an integer weight.We will as...
分类:其他好文   时间:2015-02-01 18:58:15    阅读次数:170
Balanced Binary Tree
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe...
分类:其他好文   时间:2015-01-30 16:08:22    阅读次数:149
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. 解题思路:采用中序排列的方法递归地决定每个结点的数值; #include #include #include using namespace std; //Definition...
分类:其他好文   时间:2015-01-30 16:00:24    阅读次数:131
31: Balanced Binary Tree
/* * Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which th.....
分类:其他好文   时间:2015-01-27 23:16:02    阅读次数:206
Balanced Binary Tree
检测一个树是否平衡,不需要求出高度,而是从底到顶检测是否平衡,这样才算法时间复杂度为O(n)。但是需要额外的O(logn)的空间 /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(...
分类:其他好文   时间:2015-01-27 21:55:39    阅读次数:164
Balanced Binary Tree
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe...
分类:其他好文   时间:2015-01-27 18:29:32    阅读次数:168
SPOJ 220. Relevant Phrases of Annihilation(后缀数组多次不重叠子串)
题目大意:给定N个串,求每个串至少出现两次的最长子串。 解题思路:每个字符串至少出现两次且不可重叠的最长子串:二分枚举长度后在同一分组中对每一个字符串保留一个最小的位置和一个最大的位置,最后查看是否每个串在同一组中都有至少两个后缀,并且后缀的坐标差大于枚举的长度。 POJ Problem Set (classical) 220. Relevant Phrases of Annihil...
分类:编程语言   时间:2015-01-27 18:28:33    阅读次数:193
Convert Sorted Array to Binary Search Tree
题目: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 我的解法: (1)算法思想: 二分法,数组的中间点为根节点,然后递归。 (2)代码如下: {CSDN:CODE:589537}...
分类:其他好文   时间:2015-01-26 19:21:31    阅读次数:136
SPOJ 687. Repeats(后缀数组求最长重复子串)
题目大意:给你一个串让你求出重复次数最多的连续重复子串的重复次数。 解题思路:论文上给出的解答是: 这还没完,因为经过这两个点的情况还不完备,应还可以假设起点在 [ i*j-i+1, i*j-d],其中 d = i-L/i (d = i-L%i)其意义为根据已知的匹配长度,可以将起点往前移动的范围,太靠后将不能够构造出比之前更好的解。如果要求出某个最多的连续重复子串的最小字典序子需要枚...
分类:编程语言   时间:2015-01-26 17:10:25    阅读次数:296
POJ 3264 Balanced Lineup(RMQ)
Balanced LineupTime Limit: 5000MSMemory Limit: 65536KTotal Submissions: 36513Accepted: 17103Case Time Limit: 2000MSDescriptionFor the daily milking, F...
分类:其他好文   时间:2015-01-25 16:35:41    阅读次数:183
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!