上一页 1 2 3 4 5 6 7 ··· 15 下一页
摘要: 这道题的递归比迭代要难写,recursion是一道树上带回溯,iteration几乎套层次遍历即可。 1.递归写法 说白了就是要找到深度最大的叶子节点 ?如何保证深度最大的就是最左的?——使用前序遍历 ?为什么使用的是前序遍历而不是更倾向于左边的中序遍历 前序遍历中最先访问到的就是最左边的叶子节点。 阅读全文
posted @ 2022-03-06 11:30 明卿册 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://leetcode-cn.com/problems/sum-of-left-leaves/ 要读懂题目,题目要的是左叶子之和,是左叶子不是做节点! 最开始的写法: class Solution { public int sumOfLeftLeaves(TreeNode roo 阅读全文
posted @ 2022-03-06 09:49 明卿册 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 1.问题现象: mysql installer安装进行到apply configuration的starting the server时总是会卡住: 2.问题原因:mysql服务没有root权限,无法启动服务 3.解决: windows键打开菜单栏搜索“服务”,进入到服务列表,然后找到mysql80 阅读全文
posted @ 2022-03-02 11:06 明卿册 阅读(1112) 评论(0) 推荐(0) 编辑
摘要: class Solution { public List<String> binaryTreePaths(TreeNode root) { List<String> result = new ArrayList(); if(root==null) return result; List<Intege 阅读全文
posted @ 2022-02-26 21:18 明卿册 阅读(18) 评论(0) 推荐(0) 编辑
摘要: class Solution { public boolean isBalanced(TreeNode root) { if(root == null) return true; return getHeight(root)== -1 ? false : true; } private int ge 阅读全文
posted @ 2022-02-26 15:02 明卿册 阅读(17) 评论(0) 推荐(0) 编辑
摘要: class Solution { public boolean isSymmetric(TreeNode root) { if(root == null) return true; return judge(root.left, root.right); } private boolean judg 阅读全文
posted @ 2022-02-25 22:50 明卿册 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 翻转这个操作也是需要遍历,遍历无非dfs或者bfs,dfs无非前中后序遍历。这里采用前序遍历或者后序遍历,否则有的会被翻转两次。 最重要的是,翻转的时候传入的参数是root,而非要被翻转的两个节点。 class Solution { public TreeNode invertTree(TreeNo 阅读全文
posted @ 2022-02-25 22:36 明卿册 阅读(10) 评论(0) 推荐(0) 编辑
摘要: public int lengthOfLIS(int[] nums) { int len = nums.length, ans = 1; int[] dp = new int[len]; dp[0] = 1; for(int i = 1; i < len; i++) { dp[i] = 1; for 阅读全文
posted @ 2022-02-24 22:35 明卿册 阅读(12) 评论(0) 推荐(0) 编辑
摘要: public int maxProduct(int[] nums) { int len = nums.length, ans = nums[0]; int[] dpMax = new int[len], dpMin = new int[len]; dpMax[0] = nums[0]; dpMin[ 阅读全文
posted @ 2022-02-24 22:19 明卿册 阅读(12) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int findLength(int[] nums1, int[] nums2) { int ans = 0, len1 = nums1.length, len2 = nums2.length; for(int i = 0; i < len1; i++ 阅读全文
posted @ 2022-02-23 22:59 明卿册 阅读(17) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 15 下一页