摘要: 198. House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the o... 阅读全文
posted @ 2016-03-20 21:21 背锅侠 阅读(359) 评论(0) 推荐(0) 编辑
摘要: Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You ... 阅读全文
posted @ 2016-03-20 17:15 背锅侠 阅读(121) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, flatten it to a linked list in-place.For example, Given 1 / \ 2 5 / \ \ 3 4 6The f... 阅读全文
posted @ 2016-03-17 19:17 背锅侠 阅读(125) 评论(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.clas... 阅读全文
posted @ 2016-03-09 16:37 背锅侠 阅读(167) 评论(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.class... 阅读全文
posted @ 2016-03-09 16:35 背锅侠 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example, Given n = 3, there are a total of 5 uniq... 阅读全文
posted @ 2016-03-09 15:50 背锅侠 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 解决二叉树的很多问题的方案都是基于对二叉树的遍历。遍历二叉树的前序,中序,后序三大方法算是计算机科班学生必写代码了。其递归遍历是人人都能信手拈来,可是在手生时写出非递归遍历恐非易事。正因为并非易事,所以网上出现无数的介绍二叉树非递归遍历方法的文章。可是大家需要的真是那些非递归遍历代... 阅读全文
posted @ 2016-03-09 15:24 背锅侠 阅读(302) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “T... 阅读全文
posted @ 2016-03-09 14:27 背锅侠 阅读(183) 评论(0) 推荐(0) 编辑
摘要: Given 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 tre... 阅读全文
posted @ 2016-03-09 11:30 背锅侠 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example: Given bina... 阅读全文
posted @ 2016-03-08 22:00 背锅侠 阅读(142) 评论(0) 推荐(0) 编辑