原题地址:https://oj.leetcode.com/problems/jump-game-ii/题意:Given
an array of non-negative integers, you are initially positioned at the first
index of the ...
分类:
编程语言 时间:
2014-06-12 17:38:49
阅读次数:
323
Reverse Linked List IIReverse a linked list from
positionmton. Do it in-place and in one-pass.For example:Given
1->2->3->4->5->NULL, m= 2 andn= 4,retu...
分类:
其他好文 时间:
2014-06-12 07:03:54
阅读次数:
308
移除数组中重复次数超过2次以上出现的数,但是可以允许重复2次。
这个题类似Remove Duplicates from Sorted Array,第一个想法很直接就是计数,超过2次的就忽略,依据这个思路的代码见代码一;
上面的思路可行,但是代码看着比较冗余,判断比较多。再来想想原来的数组,该数组是排好序的,如果一个数出现3次以上,那么必有A[i] == A[i-2]。所以根据这个关系可以写出比较精简的代码二。详见代码。...
分类:
其他好文 时间:
2014-06-10 19:18:39
阅读次数:
250
题目
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying t...
分类:
其他好文 时间:
2014-06-10 18:43:37
阅读次数:
254
题目
Follow up for "Unique Paths":
Now consider if some obstacles are added to the grids. How many unique paths would there be?
An obstacle and empty space is marked as 1 and 0 respective...
分类:
其他好文 时间:
2014-06-10 18:28:49
阅读次数:
207
使用sql语句创建和删除约束
主建约束:(primary key constraint);
唯一约束:(unique constraint);
检查约束:(check constraint);
默认约束:(default constraint);
外建约束:(foreign key constraint);
*********************************************...
分类:
数据库 时间:
2014-06-10 13:28:14
阅读次数:
260
以i为根节点时,其左子树构成为[0,...,i-1],其右子树构成为[i+1,...,n]构成。根结点确定时,左子树与右子树的结点个数都是确定的。这样就可以把这个问题化成子问题。因此可以用动态规划解。Sigma(左边的子树可能状态
* 右边子树可能状态) = 当前个数的结点可能的状态数。public...
分类:
其他好文 时间:
2014-06-10 12:46:05
阅读次数:
175
Gopher IITime Limit:2000MSMemory Limit:65536KTotal
Submissions:6345Accepted:2599DescriptionThe gopher family, having averted the
canine threat, must f...
分类:
其他好文 时间:
2014-06-10 10:30:00
阅读次数:
218