摘要: 问题: 给定一棵二叉树。 求给定节点target开始,距离K的所有节点。 Example 1: Input: root = [3,5,1,6,2,0,8,null,null,7,4], target = 5, K = 2 Output: [7,4,1] Explanation: The nodes 阅读全文
posted @ 2021-03-08 11:40 habibah_chang 阅读(48) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定一个字符串A,每次交换其中两个字符, 最后使得到字符串B,求最少交换次数。 Example 1: Input: A = "ab", B = "ba" Output: 1 Example 2: Input: A = "abc", B = "bca" Output: 2 Example 3: 阅读全文
posted @ 2021-03-08 10:09 habibah_chang 阅读(55) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定一个图,graph[i]代表节点 i 相连的各个节点。 求遍历完所有节点,所需要的最小路径花费。 ⚠️ 注意:可以重复经过同一条边or同一个节点。 Example 1: Input: [[1,2,3],[0],[0],[0]] Output: 4 Explanation: One pos 阅读全文
posted @ 2021-03-08 09:14 habibah_chang 阅读(56) 评论(0) 推荐(0) 编辑