- 博客(4)
- 收藏
- 关注
原创 Leetcode 分治&递归
1、Permutations 链接:https://leetcode.com/problems/permutations/ 思路一:交互数组中的两个数,递归实现 思路二: public List<List<Integer>> permute(int[] nums) { int length = nums.length; if(length == 0)
2017-01-13 21:23:40 456
原创 Leetcode 树遍历 应用
1、Binary Tree Maximum Path Sum 链接:https://leetcode.com/problems/binary-tree-maximum-path-sum/ 思路:递归,求左右子树深度,看深度差是否小于1 public boolean isBalanced(TreeNode root) { if(root == null)
2017-01-09 15:10:31 239
原创 leetcode 重建二叉树
1、Construct Binary Tree from Preorder and Inorder Traversal 链接:https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ 思路:根据先序遍历和中序遍历,重建树。递归思想,因为树节点不重复,先序的第一个为根,在中序的数
2017-01-08 22:24:21 713 1
原创 leetcode 树遍历变种
1、Sum Root to Leaf Numbers 链接:https://leetcode.com/problems/sum-root-to-leaf-numbers/ 思路:递归,改层的和 = 上层和* 10 +当前val public int sumNumbers(TreeNode root) { return sumDFS(root, 0); } p
2017-01-01 14:33:46 420
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人