摘要: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are 阅读全文
posted @ 2013-12-22 20:58 andyqee 阅读(148) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].Note:Recursive solution is trivial, could you do it iteratively?/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode... 阅读全文
posted @ 2013-12-22 16:37 andyqee 阅读(464) 评论(0) 推荐(1) 编辑
摘要: Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3Return6./** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * Tree... 阅读全文
posted @ 2013-12-22 09:49 andyqee 阅读(945) 评论(2) 推荐(0) 编辑