码迷,mamicode.com
首页 >  
搜索关键字:array 迭代    ( 43873个结果
NSNumber包装
//1.创建一个数组对象 int、float、char等等C语言的类型无法直接放到OC的数组里面 NSMutableArray*array = [NSMutableArrayarrayWithObjects:@"1",@"2",nil]; //2.使用NSNumber对NSInte...
分类:其他好文   时间:2014-04-30 00:53:19    阅读次数:519
[LeetCode] 4Sum
Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ...
分类:其他好文   时间:2014-04-29 22:40:00    阅读次数:438
语法的省略不能造成编译器的歧义
package exp { object Main { def main(args: Array[String]): Unit = { B[String].say("hello"); //B[String]后的括号可以省略,编译器知道这不是要用类型B而是要...
分类:其他好文   时间:2014-04-29 22:15:21    阅读次数:500
【javascript 引用类型(一)】
javascript 的引用类型大致分为:Object 类型、Array 类型、Date 类型、RegExp 类型、Function 类型、基本包装类型和单体内置对象。这里我们着重介绍Object 类型、Array 类型和RegExp 类型。【Object 类型】创建Object 实例的方式有两种,...
分类:编程语言   时间:2014-04-29 20:54:12    阅读次数:606
Binary Tree Postorder Traversal
借助堆栈完成迭代形式的后序遍历
分类:其他好文   时间:2014-04-29 19:22:59    阅读次数:404
Binary Tree Preorder Traversal
借助堆栈完成迭代形式的先序遍历。
分类:其他好文   时间:2014-04-29 19:03:25    阅读次数:474
STL中的Traits编程技法
最近在看读《STL源码剖析》,看到Traits编程技法这节时,不禁感慨STL源码作者的创新能力。那么什么是Traits编程技法呢?且听我娓娓道来: 我们知道容器的许多操作都是通过迭代器展开的。其中容器类似于数组,迭代器类似于指针。我们用数组来写个例子:1 int arr[5] = {1,2,3...
分类:其他好文   时间:2014-04-29 18:15:15    阅读次数:463
《Cracking the Coding Interview》——第17章:普通题——题目8
2014-04-28 23:35题目:最大子数组和问题。解法:O(n)解法。代码: 1 // 17.8 Find the consecutive subarray with maximum sum in an array. 2 // O(n) online algorithm. 3 #include...
分类:其他好文   时间:2014-04-29 16:35:28    阅读次数:429
《Cracking the Coding Interview》——第17章:普通题——题目12
2014-04-29 00:04题目:给定一个整数数组,找出所有加起来为指定和的数对。解法1:可以用哈希表保存数组元素,做到O(n)时间的算法。代码: 1 // 17.12 Given an array of integers and target value, find all pairs in ...
分类:其他好文   时间:2014-04-29 15:08:13    阅读次数:469
《Cracking the Coding Interview》——第18章:难题——题目3
2014-04-29 01:02题目:从m个整数里随机选出n个整数,要求等概率。解法:和洗牌的算法类似,每次随机抽出一个数,抽n次即可。时间复杂度O(m * n),空间复杂度O(m)。代码: 1 // 18.3 pick m integers randomly from an array of n ...
分类:其他好文   时间:2014-04-29 14:42:32    阅读次数:345
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!