魔法师 (@Constanline)Leetcode每日一题 —— 3568. 清理教室的最少移动 中发帖

思路
依旧朴素的思路。 
首先最短路径BFS是定了的。通过Hash存储坐标对应的垃圾序号,这样可以将垃圾状态压缩到  2^10 。再一个Hash记录坐标+垃圾状态对应的能量。然后就可以BFS遍历了。 
PS
今天光跟网路干仗了!Clash不知道怎么老是跳到超时的节点,即使手动指定都不行,只能重新测速。 
代码
class Solution {
    private static final int[][] directions = new int[][]{
            { -1,  0 },
            {  0, -1 },
            {  1,  0 },
            {  0,  1 }
    };
    public int minMoves(String[] classroom, int energy) {
      ...
 
 
Back to Top