2016年8月11日

摘要: Validate Binary Search Tree Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left sub 阅读全文
posted @ 2016-08-11 04:02 猛犸猴子 阅读(140) 评论(0) 推荐(0)
摘要: Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. Example Given the below binary tree: 1 / \ 2 3 ret 阅读全文
posted @ 2016-08-11 03:47 猛犸猴子 阅读(147) 评论(0) 推荐(0)

2016年8月10日

摘要: This question I used divide and conquer to do this question. I firstly divide this into left and right subproblems and then from the leaves to root re 阅读全文
posted @ 2016-08-10 09:36 猛犸猴子 阅读(98) 评论(0) 推荐(0)

2016年8月8日

摘要: Binary Tree Inorder Traversal Given a binary tree, return the inorder traversal of its nodes' values. Example Given binary tree {1,#,2,3}, 1 1 2 \ 3 2 阅读全文
posted @ 2016-08-08 10:25 猛犸猴子 阅读(163) 评论(1) 推荐(0)
摘要: 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 dept 阅读全文
posted @ 2016-08-08 08:42 猛犸猴子 阅读(112) 评论(0) 推荐(0)
摘要: Binary Tree Paths Given a binary tree, return all root-to-leaf paths. Given the following binary tree: All root-to-leaf paths are: As mentioned in the 阅读全文
posted @ 2016-08-08 06:25 猛犸猴子 阅读(135) 评论(0) 推荐(0)

2016年8月7日

摘要: Given a binary tree, return the preorder traversal of its nodes' values. Given: return [1,2,4,5,3]. Thinking: For this problem, you need to think abou 阅读全文
posted @ 2016-08-07 22:51 猛犸猴子 阅读(139) 评论(1) 推荐(0)
摘要: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). Given binary tree {3,9,20,#,#,15 阅读全文
posted @ 2016-08-07 05:20 猛犸猴子 阅读(135) 评论(1) 推荐(0)

2016年8月6日

摘要: Given a positive integer n, find the least number of perfect square numbers (for example,1, 4, 9, 16, ...) which sum to n. Given n = 12, return 3 beca 阅读全文
posted @ 2016-08-06 23:35 猛犸猴子 阅读(99) 评论(0) 推荐(0)

导航