![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
BFS
Nahida_nora
这个作者很懒,什么都没留下…
展开
-
leetcode 322
记忆化搜索,使用数组,记录val的最少硬币数量;递归加bfs;原创 2024-04-10 11:03:41 · 357 阅读 · 0 评论 -
Leetcode 314. Binary Tree Vertical Order Traversal
Leetcode 314. Binary Tree Vertical Order TraversalApproach 2: BFS without Sortingclass Solution { public List<List<Integer>> verticalOrder(TreeNode root) { List<List<Integer>> output = new ArrayList(); if (root == null)原创 2020-08-04 03:52:58 · 99 阅读 · 0 评论 -
Leetcode 742. Closest Leaf in a Binary Tree
Leetcode 742. Closest Leaf in a Binary TreeApproach #1: Convert to Graph把树转换为以k节点为中心的图,从k节点开始层序遍历,返回最先遇到的叶子结点。class Solution { public int findClosestLeaf(TreeNode root, int k) { Map<TreeNode, List<TreeNode>> graph = new HashMap()原创 2020-08-03 00:03:58 · 92 阅读 · 0 评论