Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Scratch {
- static int row = 10;
- static int column = 10;
- static int[][] mat;
- public static void main(String[] args) {
- int answer = findPath(row,column, 9999, -1);
- }
- private static int findPath(int curr_row, int curr_column, int lowest, int global_max) {
- if((curr_row == (row - 1)) && (curr_column == (column - 1)){
- return Math.max(global_max, lowest);
- }
- lowest = Math.min(lowest, mat[curr_row][curr_column]);
- int global_max1 = findPath(curr_row + 1, curr_column, lowest, global_max);
- int global_max2 = findPath(curr_row, curr_column + 1, lowest, global_max);
- return Math.max(global_max1, global_max2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement