LeetCode_329矩阵中的最长递增路径
给定一个整数矩阵,找出最长递增路径的长度。 对于每个单元格,你可以往上,下,左,右四个方向移动。 你不能在对角线方向上移动或移动到边界外(即不允许环绕)。 class Solution { public int longestIncreasingPath ( int [ ] [ ] matrix ) { int row = matrix . length ; if ( row < 1 ) return 0 ; int col = matrix [ 0 ] . length ; if ( col < 1 ) return 0 ; int res = 0 ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; for ( int i = 0 ; i < row ; i ++ ) { for ( int j = 0 ; j < col ; j ++ ) { int value = dfs ( i , j , matrix , map ) ; res = Math . max ( res , value ) ; } } return res ; } public int dfs ( int i , int j , int [ ] [ ] matrix , Map < String , Integer >