Maximum Minimum Path

Maximum Minimum Path_第1张图片
Screen Shot 2017-09-13 at 17.16.58.png
public class Solution {
    public static int find(int[][] input)
    {
        int m = input.length, n = input[0].length;
        for(int i = 0; i < m; i++)
        {
            for(int j = 0; j < n; j++)
            {
                if(i == 0 && j == 0) continue;
                int a = Integer.MIN_VALUE, b = Integer.MIN_VALUE;
                if(i - 1 >= 0) a = Math.min(input[i][j], input[i - 1][j]);
                if(j - 1 >= 0) b = Math.min(input[i][j], input[i][j - 1]);
                input[i][j] = Math.max(a, b);
//              System.out.println("i = "+ i);
//              System.out.println("j = "+ j);
//              System.out.println("input[i][j] = "+ input[i][j]);
            }
        }
        return input[m - 1][n - 1];
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int[][] input = {{2, 2, 3 ,4}, {1, 2, 3, 4},{1, 2, 3, 4}};
        System.out.println(find(input));
    }
 
}

你可能感兴趣的:(Maximum Minimum Path)