首先复习一下quicksort. 先理解partition函数,就是选序列的最后一个数作为pivot,比它小的排到它左边,比它大的在它右边,它在中间。但是它左右的部分并没有排序。 返回值是这个pivot所在的位置,pivot所在位置就是它最终的位置,也就是说比如index是5,说明它就是第6大的数。 ...
分类:
其他好文 时间:
2016-07-24 07:01:32
阅读次数:
86
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all mee ...
分类:
其他好文 时间:
2016-07-24 07:01:11
阅读次数:
127
Given an array A of integer with size of n( means n books and number of pages of each book) and k people to copy the book. You must distribute the con ...
分类:
其他好文 时间:
2016-07-24 00:30:29
阅读次数:
632
34. Search for a Range 34. Search for a Range Total Accepted: 91570 Total Submissions: 308037 Difficulty: Medium Given a sorted array of integers, fin ...
分类:
其他好文 时间:
2016-07-23 23:07:47
阅读次数:
357
18. 4Sum 18. 4Sum Total Accepted: 80288 Total Submissions: 328279 Difficulty: Medium Given an array S of n integers, are there elements a, b, c, and d ...
分类:
其他好文 时间:
2016-07-23 20:58:58
阅读次数:
147
ng-repeat高级用法:遍历数组: <li ng-repeat="item in array">{{item}}</li>遍历对象: key:对象的key value:对象的value <li ng-repeat="(key,value) in obj">{{key}} | {{value}}< ...
分类:
其他好文 时间:
2016-07-23 20:58:08
阅读次数:
138
ref:https://www.ruby-lang.org/en/documentation/quickstart/ 1. attr_accseeor :name 使 MegaGreeter.instance_methods false 的返回值(Array)多了 :id :id= 两项 mg.re ...
分类:
其他好文 时间:
2016-07-23 19:44:55
阅读次数:
167
在javascipt中,有array数组对象,object对象,正则对象,函数对象,typeof只能判断是对象,但是却不能判断属于何种对象。 记录一个方法用来判断对象属于那种对象: 使用Object.prototype.toString.call(elem).toLowerCase() 获取对象的类 ...
分类:
编程语言 时间:
2016-07-23 18:23:09
阅读次数:
179
Given an circular integer array (the next element of the last element is the first element), find a continuous subarray in it, where the sum of number ...
分类:
其他好文 时间:
2016-07-23 18:12:07
阅读次数:
178
写网页的时候经常需要在页面中打印数组,但格式特别难看,看看一个html神器吧<pre>标签,能非常标准的显示数组格式 使用的时候只需要这样打印你的数组就OK了,太好用了,神器! 只需要两句话: echo "<pre>"; print_r($array); echo "<pre>"; ...
分类:
编程语言 时间:
2016-07-23 18:05:23
阅读次数:
203