上一页 1 ··· 42 43 44 45 46 47 48 49 50 ··· 98 下一页
摘要: 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,18].思路:首先以start排序,... 阅读全文
posted @ 2014-11-24 18:24 Jessica程序猿 阅读(202) 评论(0) 推荐(0) 编辑
摘要: Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路:开始做过两两合并的链表,此时做k路合并,即将k个链表进行合并,可以先将这k个链表进行两两合并,知道合并... 阅读全文
posted @ 2014-11-24 17:02 Jessica程序猿 阅读(191) 评论(0) 推荐(0) 编辑
摘要: Implementint sqrt(int x).Compute and return the square root ofx.这里给出两种实现方法:一是二分搜索,二是牛顿迭代法。1. 二分搜索对于一个非负数n,它的平方根不会小于大于(n/2+1)。在[0, n/2+1]这个范围内可以进行二分搜索,... 阅读全文
posted @ 2014-11-24 15:59 Jessica程序猿 阅读(465) 评论(0) 推荐(0) 编辑
摘要: Given an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Your algorithm should ru... 阅读全文
posted @ 2014-11-24 12:34 Jessica程序猿 阅读(148) 评论(0) 推荐(0) 编辑
摘要: Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.C++实现代码:#inclu... 阅读全文
posted @ 2014-11-24 10:09 Jessica程序猿 阅读(186) 评论(0) 推荐(0) 编辑
摘要: Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.提交成功的代码:C++实现:#... 阅读全文
posted @ 2014-11-24 09:59 Jessica程序猿 阅读(233) 评论(0) 推荐(0) 编辑
摘要: Dynamic ProgrammingGiven a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is f... 阅读全文
posted @ 2014-11-24 08:53 Jessica程序猿 阅读(197) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o... 阅读全文
posted @ 2014-11-23 22:27 Jessica程序猿 阅读(192) 评论(0) 推荐(0) 编辑
摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu... 阅读全文
posted @ 2014-11-23 18:35 Jessica程序猿 阅读(161) 评论(0) 推荐(0) 编辑
摘要: Dynamic Programming参考:http://fisherlei.blogspot.com/2012/12/leetcode-jump-game.htmlhttp://blog.csdn.net/linhuanmars/article/details/21354751Given an a... 阅读全文
posted @ 2014-11-23 16:44 Jessica程序猿 阅读(239) 评论(0) 推荐(0) 编辑
上一页 1 ··· 42 43 44 45 46 47 48 49 50 ··· 98 下一页