11 2014 档案

摘要:Binary Tree Level Order TraversalGiven a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).Fo... 阅读全文
posted @ 2014-11-30 20:12 陆草纯 阅读(227) 评论(0) 推荐(0) 编辑
摘要:Binary Tree Zigzag Level Order TraversalGiven a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then... 阅读全文
posted @ 2014-11-30 16:58 陆草纯 阅读(1710) 评论(0) 推荐(0) 编辑
摘要:Construct Binary Tree from Preorder and Inorder TraversalGiven preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume... 阅读全文
posted @ 2014-11-30 16:08 陆草纯 阅读(2007) 评论(0) 推荐(1) 编辑
摘要:Construct Binary Tree from Inorder and Postorder TraversalGiven inorder and postorder traversal of a tree, construct the binary tree.Note:You may assu... 阅读全文
posted @ 2014-11-30 13:46 陆草纯 阅读(410) 评论(0) 推荐(0) 编辑
摘要:Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.这题思路参照Conve... 阅读全文
posted @ 2014-11-29 19:05 陆草纯 阅读(386) 评论(0) 推荐(0) 编辑
摘要:Balanced Binary TreeGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tre... 阅读全文
posted @ 2014-11-29 16:18 陆草纯 阅读(198) 评论(0) 推荐(0) 编辑
摘要:Minimum Depth of Binary TreeGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root... 阅读全文
posted @ 2014-11-29 15:56 陆草纯 阅读(205) 评论(0) 推荐(0) 编辑
摘要:Path Sum IIGiven a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tr... 阅读全文
posted @ 2014-11-29 15:47 陆草纯 阅读(267) 评论(0) 推荐(0) 编辑
摘要:Path SumGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the give... 阅读全文
posted @ 2014-11-29 15:35 陆草纯 阅读(1137) 评论(0) 推荐(0) 编辑
摘要:Flatten Binary Tree to Linked ListGiven a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / ... 阅读全文
posted @ 2014-11-29 14:56 陆草纯 阅读(361) 评论(0) 推荐(0) 编辑
摘要:Populating Next Right Pointers in Each Node IIFollow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any ... 阅读全文
posted @ 2014-11-29 11:08 陆草纯 阅读(233) 评论(0) 推荐(0) 编辑
摘要:Pascal's Triangle IIGiven an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your alg... 阅读全文
posted @ 2014-11-28 17:00 陆草纯 阅读(513) 评论(0) 推荐(0) 编辑
摘要:Intersection of Two Linked ListsWrite a program to find the node at which the intersection of two singly linked lists begins.For example, the followin... 阅读全文
posted @ 2014-11-28 16:47 陆草纯 阅读(5251) 评论(1) 推荐(0) 编辑
摘要:Best Time to Buy and Sell Stock IIISay you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the... 阅读全文
posted @ 2014-11-28 11:31 陆草纯 阅读(2581) 评论(0) 推荐(0) 编辑
摘要:Binary Tree Maximum Path SumGiven a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the be... 阅读全文
posted @ 2014-11-27 18:35 陆草纯 阅读(1738) 评论(0) 推荐(0) 编辑
摘要:Word LadderGiven two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Only one let... 阅读全文
posted @ 2014-11-27 09:51 陆草纯 阅读(2778) 评论(0) 推荐(0) 编辑
摘要:Sum Root to Leaf NumbersGiven a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-l... 阅读全文
posted @ 2014-11-26 09:53 陆草纯 阅读(848) 评论(0) 推荐(0) 编辑
摘要:Palindrome PartitioningGiven a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioni... 阅读全文
posted @ 2014-11-25 19:31 陆草纯 阅读(231) 评论(0) 推荐(0) 编辑
摘要:Clone GraphClone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are l... 阅读全文
posted @ 2014-11-24 19:24 陆草纯 阅读(3387) 评论(0) 推荐(0) 编辑
摘要:Gas StationThere areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it... 阅读全文
posted @ 2014-11-23 21:48 陆草纯 阅读(391) 评论(0) 推荐(0) 编辑
摘要:CandyThere areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following ... 阅读全文
posted @ 2014-11-22 20:09 陆草纯 阅读(145) 评论(0) 推荐(0) 编辑
摘要: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-11-20 16:58 陆草纯 阅读(1885) 评论(1) 推荐(1) 编辑
摘要:LRU CacheDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get... 阅读全文
posted @ 2014-11-19 19:18 陆草纯 阅读(407) 评论(0) 推荐(0) 编辑
摘要:Min StackDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -... 阅读全文
posted @ 2014-11-18 15:04 陆草纯 阅读(2306) 评论(0) 推荐(0) 编辑
摘要:Copy List with Random PointerA linked list is given such that each node contains an additional random pointer which could point to any node in the lis... 阅读全文
posted @ 2014-11-18 14:41 陆草纯 阅读(225) 评论(0) 推荐(0) 编辑
摘要:Word BreakGiven a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.... 阅读全文
posted @ 2014-11-16 20:21 陆草纯 阅读(751) 评论(0) 推荐(0) 编辑
摘要:Binary Tree Preorder TraversalGiven a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ ... 阅读全文
posted @ 2014-11-14 16:15 陆草纯 阅读(198) 评论(0) 推荐(0) 编辑
摘要:Binary Tree Postorder TraversalGiven a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \... 阅读全文
posted @ 2014-11-14 16:07 陆草纯 阅读(379) 评论(0) 推荐(0) 编辑
摘要:Reverse Words in a StringGiven an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click... 阅读全文
posted @ 2014-11-12 11:27 陆草纯 阅读(232) 评论(0) 推荐(0) 编辑
摘要:Maximum Product SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given... 阅读全文
posted @ 2014-11-11 16:52 陆草纯 阅读(2327) 评论(0) 推荐(0) 编辑
摘要:Find Minimum in Rotated Sorted Array IIFollow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed?Would this affect the run-... 阅读全文
posted @ 2014-11-07 15:36 陆草纯 阅读(3218) 评论(0) 推荐(1) 编辑
摘要:Find Minimum in Rotated Sorted ArraySuppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 ... 阅读全文
posted @ 2014-11-07 15:25 陆草纯 阅读(687) 评论(1) 推荐(0) 编辑
摘要:Remove Nth Node From End of ListGiven a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2... 阅读全文
posted @ 2014-11-06 20:58 陆草纯 阅读(231) 评论(0) 推荐(0) 编辑
摘要:参考资料:openclassroom线性回归(Linear Regression)为了拟合10岁以下儿童年龄(x1)与身高(y)之间的关系,我们假设一个关于x的函数h(x):h(x) =Θ0+Θ1*x1 =Θ0*x0+Θ1*x1=ΘT*x(其中x0=1, x=[x0, x1])我们的目的是求出Θ,使... 阅读全文
posted @ 2014-11-06 13:35 陆草纯 阅读(780) 评论(0) 推荐(0) 编辑
摘要:Valid PalindromeGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a pla... 阅读全文
posted @ 2014-11-05 20:19 陆草纯 阅读(216) 评论(0) 推荐(0) 编辑
摘要: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-11-04 13:22 陆草纯 阅读(219) 评论(0) 推荐(0) 编辑
摘要:Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.解法一:思路:设置一个位数记录器num,遍历所有字符串的第num位。如果都相同,则nu... 阅读全文
posted @ 2014-11-04 12:46 陆草纯 阅读(2475) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示