public int longestIncreasingPath(int[][] matrix) {
        if (matrix.length == 0 || matrix[0].length == 0) {
            return 0;
        }
        int[][] distance = new int[matrix.length][matrix[0].length];
        int max = 1;
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[0].length; j++) {
                int r = dfs(matrix, i, j, distance, Integer.MIN_VALUE);
                if (r > max) {
                    max = r;
                }
            }
        }
        return max;
    }
Date 03/10/2016
@author Tushar Roy

Given a 2D matrix find longest increasing path length in this matrix.

Time complexity is O(n*m)
Space complexity is O(n*m)

Reference
https://leetcode.com/problems/longest-increasing-path-in-a-matrix/
src/com/interview/dynamic/LongestIncreasingPath.java