码迷,mamicode.com
首页 >  
搜索关键字:题意    ( 33207个结果
[leetcode]Binary Tree Level Order Traversal @ Python
原题地址:http://oj.leetcode.com/problems/binary-tree-level-order-traversal/题意:二叉树的层序遍历的实现。解题思路:二叉树的层序遍历可以用bfs或者dfs来实现。这里使用的dfs实现,代码比较简洁。实际上,二叉树的先序遍历就是dfs实...
分类:编程语言   时间:2014-05-14 03:25:59    阅读次数:428
[leetcode]Binary Tree Level Order Traversal II @ Python
原题地址:http://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/题意:Given a binary tree, return thebottom-up level ordertraversal of its node...
分类:编程语言   时间:2014-05-12 22:03:27    阅读次数:581
[leetcode]Binary Tree Zigzag Level Order Traversal @ Python
原题地址:http://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/题意:Given a binary tree, return thezigzag level ordertraversal of its nod...
分类:编程语言   时间:2014-05-12 22:02:26    阅读次数:480
[leetcode]Minimum Depth of Binary Tree @ Python
原题地址:http://oj.leetcode.com/problems/minimum-depth-of-binary-tree/题意:Given a binary tree, find its minimum depth.The minimum depth is the number of no...
分类:编程语言   时间:2014-05-12 21:55:15    阅读次数:348
HDU - 3401 Trade
题意:让你炒股票,每天都有买进的额度和价格以及卖出的额度和价格,并规定时间和最多的持有股票是多少,而且买卖操作要隔w+1天求最高的利润 思路:显然分三种情况:不买不卖,买,卖,设dp[i][j]表示第i天持有j股票的最高利润 如果不买不卖的话就是:dp[i][j]=dp[i-1][j]                                买: dp[i][j]=max(dp[i][...
分类:其他好文   时间:2014-05-11 21:18:05    阅读次数:323
SPOJ 4487. Can you answer these queries VI splay
题目链接:点击打开链接 题意比较明显,不赘述。 删除时可以把i-1转到根,把i+1转到根下 则i点就在 根右子树 的左子树,且只有i这一个 点 #include #include #include #include using namespace std; #define N 300500 #define inf 10000000 #define L(x) tree[x].ch[0] #d...
分类:其他好文   时间:2014-05-11 21:05:52    阅读次数:365
UVA 417 - Word Index(数论)
题意:417 - Word Index 题意:每个字符串按题目中那样去映射成一个数字,输入字符串,输出数字 思路:这题还是比较水的,由于一共只有83000多个数字,所以对应一个个数字去映射就可以了,注意字符串进位的情况处理即可 代码: #include #include #include #include using namespace std; char str[10]; ma...
分类:其他好文   时间:2014-05-11 20:49:23    阅读次数:428
数位dp(求1-n中数字1出现的个数)
题意:求1-n的n个数字中1出现的个数。 解法:数位dp,dp[pre][now][equa] 记录着第pre位为now,equa表示前边是否有降数字(即后边可不可以随意取,true为没降,true为已降);常规的记忆化搜索 代码:/****************************************************** * author:xiefubao ...
分类:其他好文   时间:2014-05-11 20:48:20    阅读次数:279
UVA 10497 - Sweet Child Makes Trouble(DP+高精度)
题目链接:10497 - Sweet Child Makes Trouble 题意:n个物品,原来物品属于一个地方,现在要把物品重新放回去,问能放几种使得每个物品都与原来位置不同 思路:递推,一开始随便搞了个二维状态,dp[i][j]表示i个物品,有j个位置不同,那么dp[n][n]就是答案,递推式为: dp[i][j] = 1 (j == 0) dp[i][j] = (j - 1) * ...
分类:其他好文   时间:2014-05-11 20:25:48    阅读次数:433
UVA 580 - Critical Mass(DP)
题目链接:580 - Critical Mass 题意:一个栈,里面可以放L和U,有三个连续的U就是不安全的,问共有几种不安全的情况 思路:dp,dp[i][j][k],表示放到第i个,最后两个状态为j,k表示有没有出现不安全。然后去记忆化搜索一下就可以了 然后还有一种做法是,先考虑安全的情况,在用总情况(1 不过这题都没给数据范围,不过数据其实并不大,不然计算的时候种数一下就会超过范围了...
分类:其他好文   时间:2014-05-11 20:10:18    阅读次数:372
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!