【题目】
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this in place with constant memory.
For example,
Given input array A ...
分类:
其他好文 时间:
2014-05-18 18:25:19
阅读次数:
272
【题目】
Given an array and a value, remove all instances of that value in place and return the new length.
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
【题意】
删除数组中指定的值。不关心在新数组的后面即数组尾部留下了什么值。
【思路】
思路同Remo...
分类:
其他好文 时间:
2014-05-18 14:53:56
阅读次数:
208
题目:给一个数组和给定的目标值,要求在数组里找出三个元素,这三个元素的和最接近目标值,当然等于是最好的。
用3sum的方法,把判定条件作些修改。
int twoSum(vector &num, int start, int target)
{
if(num.size() = num.size())
return -target;
int head = start;
int t...
分类:
其他好文 时间:
2014-05-18 10:49:12
阅读次数:
217
【题目】
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.
You may not alter the values in the nodes, only n...
分类:
其他好文 时间:
2014-05-18 10:22:34
阅读次数:
367
【题目】
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
【题意】
合并K个有序链表
【思路】
归并
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For ...
分类:
其他好文 时间:
2014-05-18 09:05:40
阅读次数:
255
【题目】
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only constant space. You may not modify the values in the list, only nodes it...
分类:
其他好文 时间:
2014-05-18 08:37:57
阅读次数:
370
由于工作上的需要,把数据库中备份的联系人添加到通讯录,一般都有几百条记录,插入一条数据系统默认commit一次,这样效率就降低了,如果把所有的数据都添加进去后再commit效率就不一样,这就需要事务
没有添加事务的方法,每次添加一条记录
/**
* 单条添加数据
*
* @param contacts
* @return
*/
public boolean add(T...
分类:
移动开发 时间:
2014-05-18 07:03:31
阅读次数:
629
题目:
Given an input string, reverse the string word by word.
For example,
Given s = "the sky is blue",
return "blue is sky the".
Clarification:
What constitutes a word?
A sequence of non-spa...
分类:
其他好文 时间:
2014-05-18 04:12:07
阅读次数:
198
Given two numbers represented as strings,
return multiplication of the numbers as a string.Note: The numbers can be
arbitrarily large and are non-nega...
分类:
其他好文 时间:
2014-05-18 01:25:07
阅读次数:
288
#include #include using namespace std;class
Obj{public: Obj(void){cout obj(10); vector obj2(10,0); return
0;}结果如下://执行了构造函数2次,20次复制构造函数,析构函数22次//我想提出的...
分类:
编程语言 时间:
2014-05-17 23:51:52
阅读次数:
566