2014年8月15日

leetcode -- Merge Sorted Array

摘要: 过去已无法改变,未来又难以琢磨,我们只能把握当下[问题描述]Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space ... 阅读全文

posted @ 2014-08-15 20:21 雨歌_sky 阅读(116) 评论(0) 推荐(0) 编辑

leetcode -- Merge Intervals

摘要: 关键不是怎么想,而是怎么做[问题描述]Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15... 阅读全文

posted @ 2014-08-15 20:03 雨歌_sky 阅读(122) 评论(0) 推荐(0) 编辑

logn的斐波那契

摘要: This another O(n) which relies on the fact that if we n times multiply the matrix M = {{1,1},{1,0}} to itself (in other words calculate power(M, n )),... 阅读全文

posted @ 2014-08-15 15:13 雨歌_sky 阅读(227) 评论(0) 推荐(0) 编辑

二叉树最近公共祖先

摘要: LCA算法:后续遍历+Flag 1 int Solution::search_lca(TreeNode *root, TreeNode *node1, TreeNode *node2, int &flag, TreeNode *pres) 2 {//查找二叉树公共祖先 3 if (root ... 阅读全文

posted @ 2014-08-15 15:10 雨歌_sky 阅读(253) 评论(0) 推荐(0) 编辑

leetcode -- Implement strStr()

摘要: 反正总是有人要赢,那为什么不能是我呢~[问题描述]Implement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.[... 阅读全文

posted @ 2014-08-15 12:25 雨歌_sky 阅读(158) 评论(0) 推荐(0) 编辑

leetcode -- Pow(x, n)

摘要: 不求与人相比,但求超越自己[问题描述]Implement pow(x,n).[解题思路]任何一个数x均可以被表示成 x = K^(2^a + 2^b + .....) 1 double Solution::pow(double x, int n) 2 { 3 int flag = 1; 4 ... 阅读全文

posted @ 2014-08-15 10:10 雨歌_sky 阅读(109) 评论(0) 推荐(0) 编辑

导航