摘要: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2017-11-20 12:38 逸朵 阅读(101) 评论(0) 推荐(0)
摘要: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文
posted @ 2017-11-20 12:31 逸朵 阅读(134) 评论(0) 推荐(0)
摘要: Given a string S and a string T, count the number of distinct subsequences of S which equals T. A subsequence of a string is a new string which is for 阅读全文
posted @ 2017-11-20 12:04 逸朵 阅读(132) 评论(0) 推荐(0)
摘要: Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in th 阅读全文
posted @ 2017-11-20 11:32 逸朵 阅读(143) 评论(0) 推荐(0)
摘要: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the fo 阅读全文
posted @ 2017-11-20 09:28 逸朵 阅读(140) 评论(0) 推荐(0)
摘要: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] 阅读全文
posted @ 2017-11-20 09:12 逸朵 阅读(116) 评论(0) 推荐(0)
摘要: Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [3,2,1]. 阅读全文
posted @ 2017-11-20 05:30 逸朵 阅读(138) 评论(0) 推荐(0)
摘要: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 whic 阅读全文
posted @ 2017-11-20 05:06 逸朵 阅读(131) 评论(0) 推荐(0)
摘要: Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution sti 阅读全文
posted @ 2017-11-20 03:35 逸朵 阅读(124) 评论(0) 推荐(0)
摘要: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its ne 阅读全文
posted @ 2017-11-20 02:53 逸朵 阅读(124) 评论(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. Given inorde 阅读全文
posted @ 2017-11-20 02:41 逸朵 阅读(150) 评论(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. 阅读全文
posted @ 2017-11-20 02:32 逸朵 阅读(95) 评论(0) 推荐(0)