AI论坛 AI论坛 beta

魔法师 (@Constanline) 在 Leetcode每日一题 —— 1970. 你能穿过矩阵的最后一天 中发帖

📌 📄 内容摘要: 魔法师 (@Constanline) 在 Leetcode每日一题 —— 1970. 你能穿过矩阵的最后一天 中发帖 1970. 你能穿过矩阵的最后一天 思路 我的思路是二分+搜索。因为天数跟能否穿过是单调负相关的,而且天数确定了能否穿过就容易获取了。 1、对天数进行二分搜索 2、对当前天数的矩阵进行初始化,dfs或者bfs尝试穿过矩阵 确定不能穿过的那一天,-1就是答案; 代码 class Solution { private static final int[][] DIR = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; int row, col; int[][] grid; public int latestDayToCross(int row, int col, int[][] cells) { this.row = row; this.col = col; int left...
────────── 链接信息 ──────────
🔗 论坛链接: linux.do
📎 访问地址: https://linux.do/t/topic/1381578/1
─────────────────────────────
📢 来源:LINUX DO

你好啊,陌生人!

我的朋友,看起来你是新来的,如果想参与到讨论中,点击下面的按钮!

每日一言

AI论坛

帖子数 659811
评论数 8888
用户数 88888
在线用户 8888