Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. class Scratch {
  2. static int row = 10;
  3. static int column = 10;
  4. static int[][] mat;
  5.  
  6. public static void main(String[] args) {
  7. int answer = findPath(row,column, 9999, -1);
  8. }
  9.  
  10. private static int findPath(int curr_row, int curr_column, int lowest, int global_max) {
  11. if((curr_row == (row - 1)) && (curr_column == (column - 1)){
  12. return Math.max(global_max, lowest);
  13. }
  14. lowest = Math.min(lowest, mat[curr_row][curr_column]);
  15. int global_max1 = findPath(curr_row + 1, curr_column, lowest, global_max);
  16. int global_max2 = findPath(curr_row, curr_column + 1, lowest, global_max);
  17. return Math.max(global_max1, global_max2);
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement