Last active
February 22, 2020 10:06
-
-
Save gauravghongde/a274640d6dc1c582f06bd6a4a2da8c97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//matrix size -> n*m | |
int findMine(i, j){ | |
if(i < 0 || i > n){ | |
return -1; | |
} | |
if(j == (m-1)){ | |
return arr[i][j]; | |
} | |
if(mem[i][j] == -1){ | |
maxVal = max(findMine(i-1, j+1), | |
findMine(i, j+1), | |
findMine(i+1, j+1)); | |
memTable[i][j] = arr[i][j] + maxVal; | |
} | |
return memTable[i][j]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment