摘要: Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest... 阅读全文
posted @ 2014-11-24 22:13 Jessica程序猿 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega... 阅读全文
posted @ 2014-11-24 21:20 Jessica程序猿 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially... 阅读全文
posted @ 2014-11-24 20:10 Jessica程序猿 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑