随笔分类 - BFS
摘要:https://leetcode.cn/problems/sliding-puzzle/ 在一个 2 x 3 的板上(board)有 5 块砖瓦,用数字 1~5 来表示, 以及一块空缺用 0 来表示。一次 移动 定义为选择 0 与一个相邻的数字(上下左右)进行交换. 最终当板 board 的结果是
阅读全文
摘要:You are starving and you want to eat food as quickly as possible. You want to find the shortest path to arrive at any food cell. You are given an m x
阅读全文
摘要:都要用q 树的q里存的是下一层 图的q里存的是图中所有unvisited
阅读全文
摘要:最新加了注释的模板: 本层拿出来,放到level中,下一层的放到q中 class Solution { public List<List<Integer>> levelOrder(TreeNode root) { //初始化两个要用的数据结构 List<List<Integer>> result =
阅读全文
摘要:[抄题]: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: [英文数据结构或算法,为什么不用别的数据结构或算法]: [一句话思路]: [输入量]:空: 正常情况:特大:特小:程序里处理到的特殊情况:异
阅读全文
摘要:[抄题]: There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list of non-empt
阅读全文
摘要:[抄题]: Given an undirected graph, return true if and only if it is bipartite. Recall that a graph is bipartite if we can split it's set of nodes into t
阅读全文
摘要:[抄题]: 现在你总共有 n 门课需要选,记为 0 到 n - 1.一些课程在修之前需要先修另外的一些课程,比如要学习课程 0 你需要先学习课程 1 ,表示为[0,1]给定n门课以及他们的先决条件,判断是否可能完成所有课程? 给定 n = 2,先决条件为 [[1,0]] 返回 true给定 n =
阅读全文