码迷,mamicode.com
首页 >  
搜索关键字:spoj balnum balanced    ( 1777个结果
[LeetCode]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 diff...
分类:其他好文   时间:2015-02-12 21:29:37    阅读次数:256
leetcode 110. 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...
分类:其他好文   时间:2015-02-11 21:56:18    阅读次数:117
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...
分类:其他好文   时间:2015-02-11 21:46:20    阅读次数:170
[LeetCode]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. Example Tags Expand  Recursion Linked List 解题思路: 思路一:平衡树调整。第一步建立一个单向树...
分类:其他好文   时间:2015-02-11 14:47:17    阅读次数:139
SPOJ 4053 - Card Sorting
我们的男主现在手中有n*c张牌,其中有c(#define eps 1e-9#define FOR(i,j,k) for(int i=j;i=dp[num]) { dp[++num]=p[i].hash; }else ...
分类:其他好文   时间:2015-02-11 12:37:29    阅读次数:160
SPOJ 345 - Mixtures 区间动态规划
有n个混合物排成一排,每个混合物有一个颜色值0#include#include#include#include#include#include#include#include#include#include#include#define eps 1e-9#define ALL(x) x.begin(...
分类:其他好文   时间:2015-02-11 12:30:30    阅读次数:161
SPOJ 3943 - Nested Dolls 最长不下降子序列LIS(二分写法)
现在n(wj,hi>hj,显然是满足条件的,直接合并即可(所求序列长度不变),但是如果wi>wj,hi#include#include#include#include#include#include#include#include#include#include#include#define eps...
分类:其他好文   时间:2015-02-11 12:24:28    阅读次数:129
SPOJ 181 - Scuba diver 二维背包
潜水员要潜水,给出n个气缸(1=0;j--) { for (k=ai;k>=0;k--) { if (dp[j+t[i]][k+a[i]]>dp[j][k]+w[i]) { dp[j+...
分类:其他好文   时间:2015-02-11 12:15:02    阅读次数:128
SPOJ 3937 - Wooden Sticks 最长上升子序列LIS
给了n个(nwj,如果hi>=hj,显然符合条件,答案不需要增加。还是wi>wj,如果hi=hj,那么答案也是不需要增加。由于要使机器调整次数尽量小,因此把w降序排列,当wi=wj时,让hi>=hj(h降序排列),然后对h求最长严格上升子序列即可。#include#include#include#i...
分类:其他好文   时间:2015-02-11 12:13:08    阅读次数:106
SPOJ 3048 - DNA Sequences LCS
给出两个字符串(不长于1000),求最长公共子序列,要求:从每个串中取必须取连续k (1=k【代码链接】#include#include#include#include#include#include#include#include#include#include#include#include#d...
分类:其他好文   时间:2015-02-11 10:45:24    阅读次数:133
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!