BFS
Nahida_nora
这个作者很懒,什么都没留下…
展开
-
leetcode 322
记忆化搜索,使用数组,记录val的最少硬币数量;递归加bfs;原创 2024-04-10 11:03:41 · 371 阅读 · 0 评论 -
Leetcode 314. Binary Tree Vertical Order Traversal
Leetcode 314. Binary Tree Vertical Order Traversal Approach 2: BFS without Sorting class Solution { public List<List<Integer>> verticalOrder(TreeNode root) { List<List<Integer>> output = new ArrayList(); if (root == null)原创 2020-08-04 03:52:58 · 115 阅读 · 0 评论 -
Leetcode 742. Closest Leaf in a Binary Tree
Leetcode 742. Closest Leaf in a Binary Tree Approach #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 · 113 阅读 · 0 评论