1.数组实用方法大全 Array.isArray()在ES5之前不支持,就自己写。不过现在都到ES6了,可以不管了。 数组的遍历 splice插入、删除、换数 sort() 方法对数组的元素做原地的排序,并返回这个数组。 这是因为sort排序可能是不稳定的,默认按照字符串的Unicode码位点排序。 ...
分类:
Web程序 时间:
2016-10-02 00:48:49
阅读次数:
278
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 three integers. ...
分类:
其他好文 时间:
2016-10-02 00:42:23
阅读次数:
137
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array whic ...
分类:
其他好文 时间:
2016-10-02 00:29:22
阅读次数:
127
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of ...
分类:
其他好文 时间:
2016-10-02 00:10:19
阅读次数:
165
Write a function to find the longest common prefix string amongst an array of strings. ...
分类:
其他好文 时间:
2016-10-02 00:10:17
阅读次数:
156
Given an array of integers A and let n to be its length. Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a ...
分类:
其他好文 时间:
2016-10-01 21:41:11
阅读次数:
203
贪心,优先队列。 先看一下输入的数组乘积是正的还是负的。 ①如果是负的,也就是接下来的操作肯定是让正的加大,负的减小。每次寻找一个绝对值最小的数操作就可以了。 ②如果是正的,也是考虑绝对值,先操作绝对值最小的那个数,直到那个数字的符号发生变化就停止操作,接下来就是第①步。 ...
分类:
其他好文 时间:
2016-10-01 19:27:05
阅读次数:
229
1.数组创建及初始化 var obj=new Array(); var arr=[]; 可以延伸为长度一定的,字面量定义数组 2.堆栈 按值传递 引用类型 数组是引用类型,不是值传递, 栈:系桶自动分配和释放 ,比如函数的参数、局部变量 先进后出 一级缓存 堆:一般由程序员分配释放,程序结束后系统回... ...
分类:
编程语言 时间:
2016-10-01 19:10:20
阅读次数:
155
import java.util.Scanner ; public class HeapSort{ int[] h ; int n ; public void swap(int[] array, int x, int y){ //简单的交换函数; int t = array[x] ; array[x ...
分类:
其他好文 时间:
2016-10-01 15:00:52
阅读次数:
141
1. min/max heap 看到K神马的基本上就是min/max heap. (1) Find the K closest points to the origin in a 2D plane, given an array containing N points. 1 public stati ...
分类:
其他好文 时间:
2016-10-01 14:54:26
阅读次数:
200