08 2016 档案
233. Number of Digit One *HARD* -- 从1到n的整数中数字1出现的次数
摘要:Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. For example:Given n = 13,Return
阅读全文
231. Power of Two 342. Power of Four -- 判断是否为2、4的整数次幂
摘要:231. Power of Two Given an integer, write a function to determine if it is a power of two. 342. Power of Four Given an integer (signed 32 bits), write
阅读全文
图片填充UIImageView大小不对
摘要:http://www.2cto.com/kf/201507/412894.html UIView的contentMode属性: 默认为Scale To Fill,会保留view的比例,不会完全按照设定的高度和宽度。 可以改为Aspect Fill。但它是把ImageView的大小根据图片大小进行调整
阅读全文
App crash 报错 'NSUnknownKeyException'
摘要:报错: *** Terminating app due to uncaught exception , reason: '[<NSObject 0x6e36ae0> setValue:forUndefinedKey:]: this class is not key value coding-comp
阅读全文
App开发
摘要:设置App图标 在Assets.xcassets的AppIcon中添加图片。 设置App名称 工程 -》 Info -》 添加Key:“Bundle Display Name“ 和 Value:App名称 设置App启动图片 在Assets.xcassets的LaunchImage中添加图片。 工程
阅读全文
229. Majority Element II -- 找出数组中出现次数超过 ⌊ n/3 ⌋ 次的数
摘要:Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.
阅读全文
218. The Skyline Problem *HARD* -- 矩形重叠
摘要:A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are give
阅读全文
221. Maximal Square -- 矩阵中1组成的最大正方形
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. For example, given the following ma
阅读全文
输出有序数组的中两个元素差值为指定值diff的两个元素
摘要:题目: 输出有序数组的中两个元素差值为指定值diff的两个元素。 思路: 这与输出两个元素的和的值为一定值类似,需要两个指针,不同的是:指针不是一左一右,而是一前一后。 如果差值等于diff,则返回;如果差值大于diff,则左指针右移;如果差值小于diff,则右指针右移。
阅读全文
5. Longest Palindromic Substring -- 最长回文字串
摘要:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longes
阅读全文
79. 212. Word Search *HARD* -- 字符矩阵中查找单词
摘要:79. Word Search Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent ce
阅读全文
84. Largest Rectangle in Histogram *HARD* -- 求柱状图中的最大矩形面积
摘要:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist
阅读全文
18. 4Sum -- 找到数组中和为target的4个数
摘要: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
阅读全文
201. Bitwise AND of Numbers Range -- 连续整数按位与的和
摘要:Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. For example, given the range [5,
阅读全文
368. Largest Divisible Subset -- 找出一个数组使得数组内的数能够两两整除
摘要:Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or
阅读全文
198. 213. 337. House Robber -- 不取相邻值的最大值
摘要:198. House Robber You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only cons
阅读全文
190. Reverse Bits -- 按位反转
摘要:Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), retur
阅读全文
189. Rotate Array -- 将数组前一半移到后一半
摘要:Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Not
阅读全文
166. Fraction to Recurring Decimal -- 将除法的商表示成字符串(循环节用括号表示)
摘要:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating
阅读全文
179. Largest Number -- 数字字符串比较大小
摘要:Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed n
阅读全文
172. Factorial Trailing Zeroes -- 求n的阶乘末尾有几个0
摘要:Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. (1) (2)
阅读全文
164. Maximum Gap *HARD* -- 无序数组找出排序后连续元素的最大间隔
摘要:Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Try to solve it in linear time/space. Return
阅读全文
viewDidLoad && loadView
摘要:viewDidLoad 方法在controller加载了相关的views后被调用,而不论这些views存储在nib文件里还是在loadView函数中生成。 loadView 方法在控制器的 view 为 nil 的时候被调用。 此方法用于以编程的方式创建 view 的时候用到。loadView 是使
阅读全文
给文本标签UILabel添加长按复制功能
摘要:http://www.111cn.net/sj/iOS/104236.htm http://blog.csdn.net/lrenjun/article/details/12582927 自定义一个可复制的标签类,使其能够响应Touch事件并显示复制菜单。
阅读全文
函数与方法(方法前 + - 号)
摘要:方法:方法是Objective-C独有的一种结构,只能在Objective-C中声明、定义和使用,C语言不能声明、定义和使用。 1、类方法以+号开头,对象方法以-号开头 + (void) init; // 类方法 - (void) show; // 对象方法 2、在@interface和@end之间
阅读全文
1362 : 修补木桶 -- 最长的最短边
摘要:描述 一只木桶能盛多少水,并不取决于桶壁上最高的那块木板,而恰恰取决于桶壁上最短的那块。 已知一个木桶的桶壁由N块木板组成,第i块木板的长度为Ai。 现在小Hi有一个快捷修补工具,每次可以使用修补工具将连续的不超过L块木板提高至任意高度。 已知修补工具一共可以使用M次(M*L<N),如何修补才能使最
阅读全文
149. Max Points on a Line *HARD* 求点集中在一条直线上的最多点数
摘要:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
阅读全文
148. Sort List -- 时间复杂度O(n log n)
摘要:Sort a linked list in O(n log n) time using constant space complexity. 归并排序
阅读全文
133. Clone Graph 138. Copy List with Random Pointer 拷贝图和链表
摘要:133. Clone Graph Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected graph serialization:
阅读全文
debug && release
摘要:http://www.cnblogs.com/awpatp/archive/2009/11/05/1597038.html Debug 通常称为调试版本,它包含调试信息,并且不作任何优化,便于程序员调试程序。 Release 称为发布版本,它往往是进行了各种优化,使得程序在代码大小和运行速度上都是最
阅读全文
静态库 && 动态库
摘要:http://weihe6666.iteye.com/blog/1100065 http://www.cnblogs.com/skynet/p/3372855.html 静态库: 在链接阶段,将汇编生成的目标文件.o与引用到的库一起链接打包到可执行文件中。 静态库对函数库的链接是放在编译时期完成的。
阅读全文
#define && const
摘要:(1) 编译器处理方式不同 define宏是在预处理阶段展开。 const常量是编译运行阶段使用。 (2) 类型和安全检查不同 define宏没有类型,不做任何类型检查,仅仅是展开。 const常量有具体的类型,在编译阶段会执行类型检查。 (3) 存储方式不同 define宏仅仅是展开,有多少地方使
阅读全文
ScrollView嵌套StackView提示需要宽度和高度限制
摘要:场景: 在一个xib的view中,添加一个ScrollView,再在这个ScrollView中添加一个StackView,StackView中不加控件(用代码动态加)。 问题: 提示ScrollView的X和Y没有确定。 解决: 1. 添加Equal Width。 2. 添加Height=固定值,然
阅读全文
石化盈科
摘要:1. 讲快速排序过程、时间复杂度。 让说时间复杂度为O(n)的排序算法。提示用空间换时间。 我想用计数排序。 他给出的方法是,把1000个数,哈希到100个桶中,每个桶范围为[0,10], (10, 20]...每个桶内部简单排序。 2. 从github上拿到一个项目,如何了解。 看说明 -》知道项
阅读全文
重载Array类的contains方法
摘要:var allFilters = self.filtersContainer?.filters ?? [OpalFilter]() if let sorter = filtersContainer?.sorter { if allFilters.contains ({ (filter: OpalFilter) -> Bool in if filter.groupName ...
阅读全文
浙公网安备 33010602011771号