上一页 1 2 3 4 5 6 7 8 ··· 34 下一页
摘要: Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree{3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7return its bottom-up level order traversal as:[ [15,7] [9,20], [3],]conf... 阅读全文
posted @ 2014-03-11 21:38 七年之后 阅读(127) 评论(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.Have you been asked this question in an interview?Yes/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right... 阅读全文
posted @ 2014-03-11 21:04 七年之后 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 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-03-11 19:39 七年之后 阅读(155) 评论(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.Have you been asked this question in an interview?Yes/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right;... 阅读全文
posted @ 2014-03-11 19:30 七年之后 阅读(143) 评论(0) 推荐(0) 编辑
摘要: A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total number of ways to decode it.For example,Given encoded message"12", it cou 阅读全文
posted @ 2014-03-11 16:12 七年之后 阅读(105) 评论(0) 推荐(0) 编辑
摘要: The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0.For example, givenn= 2, return[0,1,3,2]. Its gray code s 阅读全文
posted @ 2014-03-11 13:12 七年之后 阅读(116) 评论(0) 推荐(0) 编辑
摘要: Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation ofs1="great": great / \ gr eat / \ / \g r e at / \ a tTo scramble the string, we may choose any non-leaf no... 阅读全文
posted @ 2014-03-11 11:35 七年之后 阅读(162) 评论(0) 推荐(0) 编辑
摘要: Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's.1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \ \ 2 1 ... 阅读全文
posted @ 2014-03-10 17:07 七年之后 阅读(156) 评论(0) 推荐(0) 编辑
摘要: Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at mosttwotransactions.Note:You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).Have you be 阅读全文
posted @ 2014-03-10 12:18 七年之后 阅读(166) 评论(0) 推荐(0) 编辑
摘要: Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at 阅读全文
posted @ 2014-03-09 21:43 七年之后 阅读(164) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 34 下一页