上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 30 下一页
摘要: https://github.com/CyC2018/CS-Notes/blob/master/notes/Java%20%E8%99%9A%E6%8B%9F%E6%9C%BA.md#%E7%B1%BB%E5%8A%A0%E8%BD%BD%E5%99%A8%E5%88%86%E7%B1%BB 阅读全文
posted @ 2020-05-08 08:02 弓呆的胖次 阅读(112) 评论(0) 推荐(0) 编辑
摘要: https://www.cnblogs.com/s-b-b/p/8334593.html 阅读全文
posted @ 2020-05-07 18:53 弓呆的胖次 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 首先,可以排序,之后遍历,不过时间复杂度是nlogn,代码如下,不细说 class Solution { public int singleNumber(int[] nums) { Arrays.sort(nums); if(nums.length==1)return nums[0]; int le 阅读全文
posted @ 2020-05-07 16:33 弓呆的胖次 阅读(96) 评论(0) 推荐(0) 编辑
摘要: https://leetcode-cn.com/problems/linked-list-cycle-ii/solution/huan-xing-lian-biao-ii-by-leetcode/ 思路: (1)首先判断有没有环,把quick与slow设置为head,当满足2的条件时,slow每次移 阅读全文
posted @ 2020-05-07 16:17 弓呆的胖次 阅读(290) 评论(0) 推荐(0) 编辑
摘要: 快慢指针即可 public class Solution { public boolean hasCycle(ListNode head) { if(head==null||head.next==null) return false; ListNode slow=head; ListNode qui 阅读全文
posted @ 2020-05-07 15:49 弓呆的胖次 阅读(145) 评论(0) 推荐(0) 编辑
摘要: https://github.com/913624784/Interview-Notebook 阅读全文
posted @ 2020-05-07 15:09 弓呆的胖次 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 思路: class Solution { int maxDepth = -1; int sum = 0; public int deepestLeavesSum(TreeNode root) { return dfs(root, 0); } private int dfs(TreeNode root 阅读全文
posted @ 2020-05-07 14:11 弓呆的胖次 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 思路:明显可以使用回溯法,和112题很像,先把当前根节点选中,加入temp,之后使用sum1减去根节点数值,然后到了叶子结点,判断sum1是否为零,来判断当前路径是不是符合要求。 遇到符合要求的叶子结点,把当前的路径加入res里面。 假如当前根节点不是叶子结点,递归调用函数处理左右子树 对左右子树的 阅读全文
posted @ 2020-05-07 11:20 弓呆的胖次 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 思路: 最直接的方法就是利用递归,遍历整棵树:如果当前节点不是叶子,对它的所有孩子节点,递归调用 hasPathSum 函数,其中 sum 值减去当前节点的权值;如果当前节点是叶子,检查 sum 值是否为 0,也就是是否找到了给定的目标和。 class Solution {//看笔记,思路 publ 阅读全文
posted @ 2020-05-07 10:49 弓呆的胖次 阅读(139) 评论(0) 推荐(0) 编辑
摘要: https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/solution/li-jie-zhe-dao-ti-de-jie-shu-tiao-jian-by-user7208/ 思路:有个特殊情况,比如树是1,2.这样的话,根节点为 阅读全文
posted @ 2020-05-07 10:35 弓呆的胖次 阅读(137) 评论(0) 推荐(0) 编辑
上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 30 下一页