Given a matrix with each cell containing each number of candies, and a constraint that you can move only right or down, from the top left corner to the bottom right corner, find the path that gets you maximum candies.

Note: This result will print the all the possible path cost , you can fetch the path with maximum candies.


int matrix[][] = {{0,5,7},{7,9,1},{2,7,11}};
int rows = matrix.length,column = matrix[0].length;
System.out.println(“rows : “+rows );
System.out.println(“columns : “+column);
int TotalSum = 0,sum=0;



private void FindTheTotalSum(int i, int j, int sum,int rows,int column,int[][] arr) {

System.out.println(sum+” sum of the path”);
sum = sum + arr[j][i];
FindTheTotalSum(i+1, j, sum, rows, column,arr);
FindTheTotalSum(i, j+1, sum, rows, column,arr);