题目
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.
方法
遍...
分类:
其他好文 时间:
2014-06-11 00:41:44
阅读次数:
207
Given an array of integers, every element
appears twice except for one. Find that single one.Note: Your algorithm should
have a linear runtime complex...
分类:
其他好文 时间:
2014-06-10 21:27:22
阅读次数:
284
Given an array of integers, every element
appears three times except for one. Find that single one.Note: Your algorithm
should have a linear runtime c...
分类:
其他好文 时间:
2014-06-10 20:42:48
阅读次数:
315
1 class Solution { 2 public: 3 int
singleNumber(int A[], int n) { 4 int bits = sizeof(int)*8; 5 int result=0; 6
for(int i...
分类:
移动开发 时间:
2014-06-10 19:45:48
阅读次数:
334
移除数组中重复次数超过2次以上出现的数,但是可以允许重复2次。
这个题类似Remove Duplicates from Sorted Array,第一个想法很直接就是计数,超过2次的就忽略,依据这个思路的代码见代码一;
上面的思路可行,但是代码看着比较冗余,判断比较多。再来想想原来的数组,该数组是排好序的,如果一个数出现3次以上,那么必有A[i] == A[i-2]。所以根据这个关系可以写出比较精简的代码二。详见代码。...
分类:
其他好文 时间:
2014-06-10 19:18:39
阅读次数:
250
本章介绍在D3.js中关于如何选择,插入和删除元素。...
分类:
Web程序 时间:
2014-06-10 14:33:36
阅读次数:
280
1 class Solution { 2 public: 3 int
singleNumber(int A[], int n) { 4 int i,j; 5 for(i=0; i<n; i++) 6 { 7 for(j...
分类:
移动开发 时间:
2014-06-10 11:41:55
阅读次数:
259
int removeDuplicates(int A[], int n) {
if(n <= 1)
return n;
int newIndex = 0;
for(int i = 1; i < n; ++i){
if(A[i] != A[newIndex])
A[++newIndex] ...
分类:
其他好文 时间:
2014-06-10 10:57:49
阅读次数:
131
JQuery并没有简单的使用一个Array来存储回调函数,而是通过JQuery.Callbacks(options)返回一个self对象,此对象可以动态的add,remove和fire回调函数队列.此函数需要说明的是options参数,它是一个string,这个string由四个参数任意组合而成
options:
once:回调函数只执行一次
memory:调用add时触发回调函数使用fir...
分类:
Web程序 时间:
2014-06-10 07:31:07
阅读次数:
281
关联数组可以有两种操作:
插入一个关键字和对应的值
通过关键字查询与之对应的值
典型的应用有DNS查找。
接口
关联数组的接口如下:
public interface ST {
public Value get(Key key);
public void remove(Key key);
pub...
分类:
其他好文 时间:
2014-06-10 06:41:31
阅读次数:
215