描述 Treap模板题.支持如下几种操作: 1.插入; 2.删除; 3.rank(x); 4.kth(k); 5.pre(x); 6.suc(x); 分析 写多了就熟了...昨天看了书,今天调试的时候敲了好多遍,感觉满脑子是tree+heap. p.s. 1.rank,kth,pre,suc函数都可 ...
分类:
其他好文 时间:
2016-05-11 23:19:23
阅读次数:
152
118. Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return 119. Given an index k, return the kth row o ...
分类:
其他好文 时间:
2016-05-01 11:03:08
阅读次数:
184
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. Pascal's Triangle为给出行数,求所有结果,这题是给出任意行号,求该行的结 ...
分类:
其他好文 时间:
2016-04-30 16:53:14
阅读次数:
239
1. 问题描写叙述 给定一个二叉搜索树,找出第k小的元素。 注意:能够如果k总是存在,1≤k≤BST总元素数1 \le k \le BST总元素数。 2. 方法与思路 依据二叉搜索树的特点。中序遍历的结果即是排序好的数组。那么找出第k小的数,仅仅须要先进行一次中序遍历就可以。 /** * Defin ...
分类:
其他好文 时间:
2016-04-17 20:44:37
阅读次数:
148
题目链接:点击打开链接
思路:划分树模板题。
细节参见代码:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define Max(a,b) ((a)>(b)?(a):(...
分类:
其他好文 时间:
2016-04-16 19:16:04
阅读次数:
191
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. Note:Could you optimize your algorithm to us ...
分类:
其他好文 时间:
2016-04-12 23:53:06
阅读次数:
225
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ BST's ...
分类:
其他好文 时间:
2016-04-01 12:43:25
阅读次数:
145
The kth great number TimeLimit: 2000/1000 MS (Java/Others) MemoryLimit: 65768/65768 K (Java/Others) TimeLimit: 2000/1000 MS (Java/Others) MemoryLimit: ...
分类:
其他好文 时间:
2016-03-27 15:17:35
阅读次数:
264