随笔分类 -  leetcode解题报告

leetcode : Recover Binary Search Tree
摘要:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is ... 阅读全文

posted @ 2014-11-24 09:32 远近闻名的学渣 阅读(170) 评论(0) 推荐(0)

leetcode : Construct Binary Tree from Inorder and Postorder Traversal
摘要:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.使用分治算法可以很好的解决,... 阅读全文

posted @ 2014-11-23 21:32 远近闻名的学渣 阅读(139) 评论(0) 推荐(0)

leetcode : Convert Sorted List to Binary Search Tree
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.使用分治的思想很好解决的问题。难点有两个,1如何建立平衡二叉搜索树,2,所给的单链... 阅读全文

posted @ 2014-11-23 18:54 远近闻名的学渣 阅读(137) 评论(0) 推荐(0)

leetcode : Subsets I&II
摘要:Given a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.... 阅读全文

posted @ 2014-11-22 20:34 远近闻名的学渣 阅读(100) 评论(0) 推荐(0)

leetcode : Maximum Product Subarray
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the... 阅读全文

posted @ 2014-11-21 22:46 远近闻名的学渣 阅读(120) 评论(0) 推荐(0)

leetcode : Balanced Binary Tree
摘要:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth... 阅读全文

posted @ 2014-11-20 19:32 远近闻名的学渣 阅读(180) 评论(0) 推荐(1)

leetcode : Minimum Depth of Binary Tree
摘要:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest le... 阅读全文

posted @ 2014-11-20 14:27 远近闻名的学渣 阅读(135) 评论(0) 推荐(1)

leetcode : Distinct Subsequences
摘要:Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig... 阅读全文

posted @ 2014-11-20 13:57 远近闻名的学渣 阅读(179) 评论(1) 推荐(0)

导航