码迷,mamicode.com
首页 >  
搜索关键字:array    ( 29504个结果
Search in Rotated Sorted Array, 查找反转有序序列。利用二分查找的思想。反转序列。
问题描述:一个有序序列经过反转,得到一个新的序列,查找新序列的某个元素。12345->45123。 算法思想:利用二分查找的思想,都是把要找的目标元素限制在一个小范围的有序序列中。这个题和二分查找的区别是,序列经过mid拆分后,是一个非连续的序列。特别要注意target的上下限问题。因为是非连续,所 ...
分类:其他好文   时间:2016-06-08 22:53:49    阅读次数:239
二维数组排序
对二维数组中的 age和name 项排序,name相同的按照age排序。 需要用到PHP的内置函数 array_multisort() $arr = array( 0 =>array('name' => 'godlike','age' => 18), 1=>array('name' => 'caom ...
分类:编程语言   时间:2016-06-08 19:08:43    阅读次数:257
[PHP源码阅读]array_slice和array_splice函数
array_slice和array_splice函数是用在取出数组的一段切片,array_splice还有用新的切片替换原删除切片位置的功能。类似javascript中的Array.prototype.splice和Array.prototype.slice方法。 ...
分类:Web程序   时间:2016-06-08 15:43:54    阅读次数:197
php之利用递归写无限极分类
<?php //无限极分类 //parent 的值,是该栏目的父栏目的id 反之是 /*0 安徽 合肥 北京 海淀 中关村 上地 河北 石家庄 */ $area = array( array('id'=>1,'name'=>'安徽','parent'=>0), array('id'=>2,'name ...
分类:Web程序   时间:2016-06-08 15:43:25    阅读次数:226
C++实现希尔排序
#pragmaonce voidShellSort(int*array,size_tn) { intgap=n; while(gap>1) { gap=gap/3+1; for(size_ti=0;i<n-gap;++i) { intend=i; inttmp=array[end+gap]; while((end>=0)&&array[end]>tmp) { array[end+gap]=array[end]; ..
分类:编程语言   时间:2016-06-08 12:37:05    阅读次数:433
C++实现选择排序
#pragmaonce voidSelectSort(int*array,intn) { assert(array); intleft=0; intright=n-1; while(left<right) { intminIndex=left; intmaxIndex=right; for(inti=left;i<=right;++i) { if(array[i]<array[minIndex]) minIndex=i; if(a..
分类:编程语言   时间:2016-06-08 12:36:47    阅读次数:290
webluker刷新缓存-php版
<?phpfunctionfixEncoding($in_str){$cur_encoding=mb_detect_encoding($in_str);if($cur_encoding=="UTF-8"&&mb_check_encoding($in_str,"UTF-8"))return$in_str;elsereturnutf8_encode($in_str);}functiongetSign($data,$key){$dataList=array_keys($data);sort($..
分类:Web程序   时间:2016-06-08 12:35:48    阅读次数:214
26. Remove Duplicates from Sorted Array
题目: 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 spac ...
分类:其他好文   时间:2016-06-08 12:10:42    阅读次数:119
php empty 和空字符串区别
php empty 和空字符串区别 php empty 和空字符串区别 如果 var 是非空或非零的值,则 empty() 返回 FALSE。换句话说,""、0、"0"、NULL、FALSE、array()、var $var; 以及没有任何属性的对象都将被认为是空的,如果 var 为空,则返回 TR ...
分类:Web程序   时间:2016-06-08 10:44:39    阅读次数:210
[LeetCode] Russian Doll Envelopes 俄罗斯娃娃信封
Given an unsorted array of integers, find the length of longest increasing subsequence. For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest i ...
分类:其他好文   时间:2016-06-08 01:30:04    阅读次数:237
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!