08 2016 档案

摘要:题目描述: Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space fo... 阅读全文
posted @ 2016-08-31 23:03 zsper 阅读(146) 评论(0) 推荐(0)
摘要:题目描述: Implement int sqrt(int x).Compute and return the square root of x.如果输入的是正整数,并且,输出int类型的话,可以用二分查找的方法。 对于一个非负数n,它的平方根不会大于(n/2+1)。因... 阅读全文
posted @ 2016-08-30 19:40 zsper 阅读(251) 评论(0) 推荐(0)
摘要:题目描述: Given a linked list, swap every two adjacent nodes and return its head.For example, Given 1->2->3->4, you should return the list... 阅读全文
posted @ 2016-08-30 16:33 zsper 阅读(97) 评论(0) 推荐(0)
摘要:题目描述: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.题目大意: 给定整数 n,生成 n 个“()”排列... 阅读全文
posted @ 2016-08-29 15:56 zsper 阅读(78) 评论(0) 推荐(0)
摘要:堆排序算法简介:堆可以看为一颗完全二叉树,满足,任何一个非叶结点的值都不大于(或不小于)其左右孩子结点的值。若父亲大孩子小,则称为大顶堆;若父亲小孩子大,则称为小顶堆。 根据堆的定义,其根结点值是最大的(或最小的),因此,将一个无序序列调整为一个堆,就可以找出这个序列... 阅读全文
posted @ 2016-08-25 15:49 zsper 阅读(229) 评论(0) 推荐(0)
摘要:runtime 是一套比较底层的纯 C 语言 API, 平时写的 OC 代码都会转成 runtime 的 C 语言代码. 利用 runtime 可以动态的创建类(例如KVO的底层实现), 动态的创建修改方法和属性. 在自定义归档解档的时候 (NSCoding 技术),... 阅读全文
posted @ 2016-08-11 21:12 zsper 阅读(128) 评论(0) 推荐(0)
摘要:KVO 全称是Key Value Observing,翻译成键值观察。提供了一种当其它对象属性被修改的时候能通知当前对象的机制。KVO 的基本使用:(1)注册指定Key路径的监听器: /** 参数 * addObserver: 监听对象 ... 阅读全文
posted @ 2016-08-01 23:57 zsper 阅读(154) 评论(0) 推荐(0)