Skip to content

Instantly share code, notes, and snippets.

@gauravghongde
Last active February 22, 2020 10:06
Show Gist options
  • Save gauravghongde/a274640d6dc1c582f06bd6a4a2da8c97 to your computer and use it in GitHub Desktop.
Save gauravghongde/a274640d6dc1c582f06bd6a4a2da8c97 to your computer and use it in GitHub Desktop.
//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