Given an unsorted array, find the maximum difference between the successive elements in its sorted form.
Try to solve it in linear time/space.
Return 0 if the array contains less than 2 elements...
分类:
其他好文 时间:
2015-06-21 14:33:28
阅读次数:
214
在服务器端创建按钮添加对话框(可能用到的比较少,但是可以这么干)1 Button1.Attributes.Add("onclick","return confirm(’确认?’)"); 2 Button1.attributes.add("onclick","if(confirm(’are you ....
分类:
Web程序 时间:
2015-06-21 14:24:54
阅读次数:
165
3Sum Closest
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the thr...
分类:
其他好文 时间:
2015-06-21 13:13:56
阅读次数:
114
一 总结1 方法分为静态方法和非静态方法,静态方法不对特定的实例进行操作,且不允许引用this,非静态方法是对类的某个特定的实例进行操作,且可以用this来访改方法例子一 静态方法:public static int add(int x,int y){return x+y;}static void ...
Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].也可以和 Leetcode 118 Pascal's TriangleII 一样构造最后返回最后一行。v...
分类:
其他好文 时间:
2015-06-21 11:48:52
阅读次数:
108
A peak element is an element that is greater than its neighbors.
Given an input array where num[i] ≠ num[i+1], find a peak element and return
its index.
The array may contain multiple peaks, i...
分类:
其他好文 时间:
2015-06-21 10:43:32
阅读次数:
119
#include
int a[100000];
int Hashf(int x){
return x + 1;
}
int main()
{
int n;
scanf("%d",&n);
while(n--){
int x;
scanf("%d",&x);
int y = Hashf(x);
a[y...
分类:
其他好文 时间:
2015-06-21 10:43:08
阅读次数:
118
题目:
Merge k Sorted Lists
Merge
k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
分析:
用multiset作为小根堆,multiset的begin是value最小的结点。
注意:...
分类:
其他好文 时间:
2015-06-21 10:42:17
阅读次数:
127
三种方法中,递归最为简单,栈次之,循环最为麻烦。递归的深度如果太大则会导致栈溢出;栈的方式需要额外的辅助空间;循环编程最麻烦。
首先是递归:
//递归方法
void midPrint_r(TreeNode* root)
{//中序遍历
if(root==NULL)
return;
if(root->left)
midPrint(root->left);
c...
分类:
其他好文 时间:
2015-06-21 10:39:45
阅读次数:
109
GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]...
分类:
其他好文 时间:
2015-06-21 10:36:06
阅读次数:
121