最近在学习动态规划,那这题当然是动态规划了(不好意思剧透了)......刚开始做动态规划,想详细地分析一下,以便理解更深刻! 首先读题,题目意思是要求从两个集合s1,s2选出N个数对,他们的距离(差的绝对值)的和最小;因为s1集合小于s2集合,所以就是从s1中选出全部n个数字,从s2中也选出n...
分类:
其他好文 时间:
2015-04-01 00:18:28
阅读次数:
122
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
Sicily题目分类· 【数据结构/图论】1310 Right-Heavy Tree 笛卡尔树相关,复杂度O(N)或O(NlogN)。·1426 Phone List 电话号码前缀检索,trie树相关。·1443 Printer Queue 基本队列操作。·1149 等价表达式 判断表达式是否等价(...
分类:
其他好文 时间:
2015-03-31 12:17:34
阅读次数:
182
13907. Dice Game
Constraints
Time Limit: 1 secs, Memory Limit: 256 MB
Description
Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6- side...
分类:
其他好文 时间:
2015-03-31 09:09:29
阅读次数:
169
1063. Who's the Boss
Constraints
Time Limit: 1 secs, Memory Limit: 32 MB
Description
Several surveys indicate that the taller you are, the higher you can climb the corporate ladder. At T...
分类:
其他好文 时间:
2015-03-31 09:04:14
阅读次数:
125
1003. Hit or Miss
Constraints
Time Limit: 1 secs, Memory Limit: 32 MB
Description
One very simple type of solitaire game known as "Hit or Miss" (also known as "Frustration," "Harvest...
分类:
其他好文 时间:
2015-03-31 09:04:10
阅读次数:
200
1024. Magic Island
Constraints
Time Limit: 1 secs, Memory Limit: 32 MB
Description
There are N cities and N-1 roads in Magic-Island. You can go from one city to any other. One road only ...
分类:
其他好文 时间:
2015-03-31 09:03:59
阅读次数:
173
1050. Numbers & Letters
Constraints
Time Limit: 3 secs, Memory Limit: 32 MB
Description
In the early 80’s, a popular TV show on Dutch television was ‘Cijfers en Letters’ (Numbers and Let...
分类:
其他好文 时间:
2015-03-31 09:03:22
阅读次数:
142
1317. Sudoku
Constraints
Time Limit: 10 secs, Memory Limit: 32 MB
Description
Sudoku is a placement puzzle. The goal is to enter a symbol in each cell of a grid, most frequently a 9 ...
分类:
其他好文 时间:
2015-03-31 09:03:13
阅读次数:
209
1162. Sudoku
Constraints
Time Limit: 1 secs, Memory Limit: 32 MB , Special Judge
Description
Sudoku is a very simple task. A square table with 9 rows and 9 columns is divided to 9 sm...
分类:
其他好文 时间:
2015-03-31 09:02:53
阅读次数:
124