![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode DFS
Tech In Pieces
这个作者很懒,什么都没留下…
展开
-
LeetCode 329 longest increasing path in a matrix
Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down.Input: nums =[[9,9,4],[6,6,8],[2,1,1]]Output: 4这道题乍一看上去 就像是LIS LCS问题,但是因为可以往上下左右移动 所以这有点像DP题目而原创 2020-11-27 12:18:31 · 137 阅读 · 0 评论 -
LeetCode 207 Course Schedule
given a 2D array, represents for the class and it’s prerequesite classlike [0,1], it means that we should take class 1 before class 0.public boolean canFinish(int numCourses, int[][] prerequisites)return if it is possible for us to finish all the cours原创 2020-11-27 06:36:29 · 188 阅读 · 0 评论 -
如何检测图中的环?
从每个节点出发 判断从这个节点出发DFS 最后是不是又经过了这个节点(visited)以LC207 Course Schedule为例HashMap<Integer, List<Integer>> courseDict = new HashMap<>();boolean[] visited = new boolean[numCourses];for (int i = 0; i < numCourses; i++) { //pay attention, thi原创 2020-11-27 05:48:33 · 631 阅读 · 0 评论