[LeetCode]Longest Increasing Path in a Matrix
摘要:题目: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
阅读全文
[LeetCode]Course Schedule
摘要:题目:Course Schedule 给定了n各课程[0,n-1]和课程之间的依赖关系,课程i必须先完成课程j,即:课程i依赖于课程j。判断这些课程能否修完。 思路: 这些课程学习过程类似于拓扑排序,终点是要判断课程学习顺序(依赖关系)中是否有环,如果有环,则不能修完全部课程。 课程可以看成点,课程
阅读全文
[LeetCode]Surrounded Regions
摘要:题目:Surrounded Regions 给定一个二维矩阵由'x'和'o'表示,其中o被x包围了,如果o上下左右中有其他的o,则被看做是连在一起的,而一起的o中有一个贴边了,就表示这些o都是活的。死的o要替换成x。 思路: 采用广度优先搜索或深度优先搜索来找到连在一起的o;只要遍历过程中有一个贴边
阅读全文