题目链接 https://leetcode-cn.com/problems/binary-tree-maximum-path-sum/ 题解 递归解法 路径:一条从树中任意节点出发,达到任意节点的序列。该路径至少包含一个节点,且不一定经过根节点。 这道题和LeetCode687最长同值路径和Leet ...
分类:
其他好文 时间:
2020-07-27 23:35:37
阅读次数:
74
[编程题] lc 169. 多数元素 题目 输入输出 Java代码(方法1:借用哈希表计数) //方法1:借助哈希 public int majorityElement(int[] nums) { HashMap<Integer,Integer> map = new HashMap<>(); for ...
分类:
其他好文 时间:
2020-07-27 09:38:33
阅读次数:
51
给定一个平衡括号字符串 S,按下述规则计算该字符串的分数: () 得 1 分。 AB 得 A + B 分,其中 A 和 B 是平衡括号字符串。 (A) 得 2 * A 分,其中 A 是平衡括号字符串。 示例 1: 输入: "()" 输出: 1 示例 2: 输入: "(())" 输出: 2 示例 3: ...
分类:
其他好文 时间:
2020-07-26 23:24:27
阅读次数:
113
题目链接 https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/ 题解一 递归解法 我写的 说明详见注释 // Problem: LeetCode 111 // URL: https://leetcode-cn.com/probl ...
分类:
其他好文 时间:
2020-07-26 19:32:58
阅读次数:
60
eclipse中选择->window->show view->other弹出对话框中选择general下面找problems然后双击,即可查看红叉原因. 我的项目报 :An error occurred while filtering resources 解决方案: 1.右键项目 2找到maven ...
分类:
系统相关 时间:
2020-07-26 19:12:44
阅读次数:
88
链接:https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNod ...
分类:
其他好文 时间:
2020-07-26 19:03:29
阅读次数:
62
题目描述 https://leetcode-cn.com/problems/subtree-of-another-tree/ 题解 我写的 两层DFS、双重DFS 其它题解一般也是这个思路 // Problem: LeetCode 572 // URL: https://leetcode-cn.co ...
分类:
其他好文 时间:
2020-07-26 19:01:52
阅读次数:
62
链接:https://leetcode-cn.com/problems/path-sum/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode ...
分类:
其他好文 时间:
2020-07-26 19:00:19
阅读次数:
52
https://leetcode-cn.com/problems/longest-increasing-path-in-a-matrix/ 这个题是看到被人的面经来刷的。 自己想的dp实现出来是错的,思路完全乱掉了。先贴代码吧。 class Solution { public int longest ...
分类:
其他好文 时间:
2020-07-26 15:03:03
阅读次数:
349
题目链接 https://leetcode-cn.com/problems/merge-two-binary-trees/ 题解 递归解法 解法见代码注释 // Problem: LeetCode 617 // URL: https://leetcode-cn.com/problems/merge- ...
分类:
其他好文 时间:
2020-07-26 01:03:49
阅读次数:
54