上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 44 下一页
摘要: 问题: 给定一棵二叉树, 求距离root最远距离d,所有节点所在的公共父节点。 Example 1: Input: root = [3,5,1,6,2,0,8,null,null,7,4] Output: [2,7,4] Explanation: We return the node with va 阅读全文
posted @ 2021-03-09 15:28 habibah_chang 阅读(44) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定一个无向图,n个节点 每条边可分为0个or多个node, 求从节点0开始,走maxMoves步,总共能经过多少个node。 Example 1: Input: edges = [[0,1,10],[0,2,1],[1,2,2]], maxMoves = 6, n = 3 Output: 阅读全文
posted @ 2021-03-09 13:15 habibah_chang 阅读(65) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定一个迷宫数组: @:起点 #:墙壁 a~f:key A~F:lock 从起点开始走,遇到key,可以拾得,用于开启后续遇到的lock,(若遇到lock前没有拾得对应key,那么无法通过) 墙壁也无法通过。求要获得所有的key,最少走的步数。 不可能获得所有的key的话,返回-1。 Exa 阅读全文
posted @ 2021-03-09 10:16 habibah_chang 阅读(53) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定一棵二叉树。 求给定节点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) 编辑
摘要: 问题: 给定m*n的二维数组,由0和1构成。 1代表陆地,0代表海洋。 求在任意一个0的位置填上陆地 1,使得获得最大面积陆地,求这个陆地的面积。 Example 1: Input: grid = [[1,0],[0,1]] Output: 3 Explanation: Change one 0 t 阅读全文
posted @ 2021-03-07 13:22 habibah_chang 阅读(67) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定多条bus线路,routes[i]代表 bus i 的所有经停站点。 给定source起始站,和target目标站,求最少换乘几辆车能到达目的地。 Example 1: Input: routes = [[1,2,7],[3,6,7]], source = 1, target = 6 O 阅读全文
posted @ 2021-03-07 11:54 habibah_chang 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定n个地点,以及地点之间的航班和费用。 求从src到dst,中转最多k次以内,花费最少的费用。 Example 1: Input: n = 3, edges = [[0,1,100],[1,2,100],[0,2,500]] src = 0, dst = 2, k = 1 Output: 阅读全文
posted @ 2021-03-07 11:15 habibah_chang 阅读(76) 评论(0) 推荐(0) 编辑
摘要: 问题: 滑动拼图。 给定2*3的一个拼图,有1~5代表每个格子的拼图,0代表空,其他位置的拼图可以滑动到这里。 求给定现在状态的拼图,是否最终能滑动到 1 2 3 4 5 0 的状态。 可以的话,需要最少多少步。 不可以的话,返回-1。 Examples: Input: board = [[1,2, 阅读全文
posted @ 2021-03-06 16:32 habibah_chang 阅读(61) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 44 下一页