水题,注意数据范围即可#include #include #include using
namespace std;typedef pair Point;int main(){ int x,y; cin >> x >>y;
Point a,b; if((x>0 && y > ...
分类:
其他好文 时间:
2014-06-16 10:47:47
阅读次数:
226
原题地址:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/题意:Given
a sorted linked list, delete all nodes that have duplicate number...
分类:
编程语言 时间:
2014-06-16 10:40:35
阅读次数:
340
原题地址:https://oj.leetcode.com/problems/search-in-rotated-sorted-array-ii/题意:Follow
up for "Search in Rotated Sorted Array":What ifduplicatesare allowed...
分类:
编程语言 时间:
2014-06-16 08:20:54
阅读次数:
307
原题地址: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