随笔分类 -  binary

[leecode]Scramble String
摘要:Scramble StringGiven a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible... 阅读全文

posted @ 2014-09-01 23:38 喵星人与汪星人 阅读(146) 评论(0) 推荐(0) 编辑

[leetcode]Search a 2D Matrix
摘要:Search a 2D MatrixWrite an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row... 阅读全文

posted @ 2014-08-11 20:07 喵星人与汪星人 阅读(133) 评论(0) 推荐(0) 编辑

[leetcode]Maximum Subarray
摘要:Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−... 阅读全文

posted @ 2014-08-10 19:47 喵星人与汪星人 阅读(202) 评论(0) 推荐(0) 编辑

[leetcode]Search in Rotated Sorted Array
摘要:Search in Rotated Sorted ArraySuppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).... 阅读全文

posted @ 2014-08-09 16:57 喵星人与汪星人 阅读(268) 评论(0) 推荐(0) 编辑

[leetcode]Search for a Range
摘要:Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity ... 阅读全文

posted @ 2014-08-09 16:10 喵星人与汪星人 阅读(273) 评论(0) 推荐(0) 编辑

[leetcode]Search Insert Position
摘要:Search Insert PositionGiven a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if ... 阅读全文

posted @ 2014-08-09 15:47 喵星人与汪星人 阅读(223) 评论(0) 推荐(0) 编辑

[leetcode]Divide Two Integers
摘要:Divide Two IntegersDivide two integers without using multiplication, division and mod operator.不用* 、/、%来做除法。只能加减了啊亲!算法思路:一个一个加上去必超时,例如dividend = Integ... 阅读全文

posted @ 2014-08-08 18:30 喵星人与汪星人 阅读(315) 评论(0) 推荐(0) 编辑

[leetcode]Median of Two Sorted Arrays
摘要:Median of Two Sorted ArraysThere are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run... 阅读全文

posted @ 2014-08-08 15:13 喵星人与汪星人 阅读(233) 评论(0) 推荐(0) 编辑

[leetcode]Sqrt(x)
摘要:Sqrt(x)Implementint sqrt(int x).Compute and return the square root ofx.【注意】:1.本题int类型可能会溢出,因此不能用乘法运算,应尽量用除法。2. 绝大多数数字都不是可开方的,该如何得到比较近的结果呢?算法思路:思路1:顺序遍... 阅读全文

posted @ 2014-08-08 00:05 喵星人与汪星人 阅读(301) 评论(0) 推荐(0) 编辑

[leetcode]Single Number II
摘要:Single Number IIGiven an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a lin... 阅读全文

posted @ 2014-08-07 22:26 喵星人与汪星人 阅读(167) 评论(0) 推荐(0) 编辑

[leetcode]Single Number
摘要:Single NumberGiven an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runti... 阅读全文

posted @ 2014-08-01 00:52 喵星人与汪星人 阅读(121) 评论(0) 推荐(0) 编辑