Longest Increasing Path in a Matrix
1 | Given an integer matrix, find the length of the longest increasing path. |
对每个格子找出以此为起点用dfs找出最长的,之后,找出所有的各自的最长的。对每个格子找出最长的时候记录下来,因为格子不一定是起点,有更小的话找到该格子,直接加上就行了,不用在找一遍。
1 | Given an integer matrix, find the length of the longest increasing path. |
对每个格子找出以此为起点用dfs找出最长的,之后,找出所有的各自的最长的。对每个格子找出最长的时候记录下来,因为格子不一定是起点,有更小的话找到该格子,直接加上就行了,不用在找一遍。