【题目】
Given inorder and postorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
【解析】
题意:根据二叉树中序遍历和后序遍历的结果,构造该二叉树。
首先明确一下,中序遍...
分类:
其他好文 时间:
2014-11-27 10:48:01
阅读次数:
117
(贪心)HDU 1789 解题报告
思路:
既然要让被扣掉的分数最少,那么必然是对分数高的作业优先安排。注意题中有一个不是很明显的条件可以支持这一点:完成每份作业都需要一天。这样就避免了优先完成一份分数高的作业而导致n(n>1)份作业没有完成,而且这n份作业分数和比一份分数高的作业还要大的情况。
方法:
对于所有的作业,按照分数从高到低排序,分数相同时,截止时间小的排在前面。另外初始化一个大小为n的数组,用来保存某一天是否已经被占用。然后开始贪心,对于每份作业,看从当天到当前之前的时间里面,有没有空...
分类:
其他好文 时间:
2014-11-27 09:17:10
阅读次数:
164
Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand...
分类:
其他好文 时间:
2014-11-26 22:25:26
阅读次数:
478
Max Points on a LineGiven n points on a 2D plane, find the maximum number of points that lie on the same straight line.SOLUTION 1:全部的点扫一次,然后计算每一个点与其它点...
分类:
其他好文 时间:
2014-11-26 20:37:37
阅读次数:
219
原题地址:https://oj.leetcode.com/problems/partition-list/题目内容:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nod...
分类:
其他好文 时间:
2014-11-26 18:47:01
阅读次数:
196
1031_Campus题目链接:http://soj.me/1031题目大意:给出四个校区的一些地点之间的距离,地点名用字符串来表示,问某两个地点之间的最短路径长度,典型的单源最短路径题目思路:单源最短路径问题可以用dijkstra算法实现,这道题比较麻烦的是用字符串来表示地点,我用的处理方法是建立...
分类:
其他好文 时间:
2014-11-26 10:56:02
阅读次数:
232
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ...
分类:
其他好文 时间:
2014-11-26 01:05:29
阅读次数:
166
Gray CodeThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the t...
分类:
其他好文 时间:
2014-11-25 22:47:02
阅读次数:
245
有史以来第一届面向社会征题的NOIp结束了。最开始以为面向社会征题会很难,但是这是我参加的最水的一次NOIp了。由于停了两月的课,所以现在正在补文化科目就没时间打代码了。所以所有的题目就均不给出代码了啦啦啦~为了方便没有参加NOIP的童鞋们我把题目网址放到了每道题题解的最后。晚了两周的题解如下:Da...
分类:
其他好文 时间:
2014-11-25 00:01:20
阅读次数:
351
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4803解题报告:有一个记录器,一共有两个按钮,还有两行屏幕显示,第一行的屏幕显示的是数目,第二行的屏幕显示的是总价,按第一行的按钮表示单价不变,数量加1,同时第二行的总价会根据当前的单价进行相应的增加,然...
分类:
其他好文 时间:
2014-11-24 23:57:12
阅读次数:
271