@Test public void getMatrixHeavy() { int n = 3; int[][] array = {{1, 3, 3}, {2, 1, 3}, {2, 2, 1}}; System.out.println("getMatrixHeavy, n is: " + n + ", res is: " + DataUtil.getMatrixHeavy(array, n, n)); }
public static int getMatrixHeavy(int[][] matrix, int m, int n) { int[][] dpArray = new int[m][n]; int sum = 0; for (int i = 0; i < m; i++) { sum += matrix[i][0]; dpArray[i][0] = sum; } sum = 0; for (int j = 0; j < n; j++) { sum += matrix[0][j]; dpArray[0][j] = sum; } for (int i = 1; i < m; i++) { for (int j = 1; j < n; j++) { dpArray[i][j] = matrix[i][j] + Math.max(dpArray[i - 1][j], dpArray[i][j - 1]); } } return dpArray[m - 1][n - 1]; }
DataUtil { public static int getMatrixHeavy(int[][] matrix, int m, int n) { int[][] dpArray = new int[m][n]; int sum = 0; for (int i = 0; i < m; i++) { sum += matrix[i][0]; dpArray[i][0] = sum; } sum = 0; for (int j = 0; j < n; j++) { sum += matrix[0][j]; dpArray[0][j] = sum; } for (int i = 1; i < m; i++) { for (int j = 1; j < n; j++) { dpArray[i][j] = matrix[i][j] + Math.max(dpArray[i - 1][j], dpArray[i][j - 1]); } } return dpArray[m - 1][n - 1]; } }
DataUtil { public static int getMatrixHeavy(int[][] matrix, int m, int n) { int[][] dpArray = new int[m][n]; int sum = 0; for (int i = 0; i < m; i++) { sum += matrix[i][0]; dpArray[i][0] = sum; } sum = 0; for (int j = 0; j < n; j++) { sum += matrix[0][j]; dpArray[0][j] = sum; } for (int i = 1; i < m; i++) { for (int j = 1; j < n; j++) { dpArray[i][j] = matrix[i][j] + Math.max(dpArray[i - 1][j], dpArray[i][j - 1]); } } return dpArray[m - 1][n - 1]; }  }
DataUtil { public static int getMatrixHeavy(int[][] matrix, int m, int n) { int[][] dpArray = new int[m][n]; int sum = 0; for (int i = 0; i < m; i++) { sum += matrix[i][0]; dpArray[i][0] = sum; } sum = 0; for (int j = 0; j < n; j++) { sum += matrix[0][j]; dpArray[0][j] = sum; } for (int i = 1; i < m; i++) { for (int j = 1; j < n; j++) { dpArray[i][j] = matrix[i][j] + Math.max(dpArray[i - 1][j], dpArray[i][j - 1]); } } return dpArray[m - 1][n - 1]; }  static int getMatrixHeavy(int[][] matrix, int m, int n); static int maxSequenceSum(int[] array); static int fibonacciRecursive(int n); static int fibonacci(int n); static int findMaxUnContinuousSum(int[] array); static void findContinuousSequenceMethod1(int n); static void findContinuousSequenceMethod2(int n); static void findContinuousSequenceMethod3(int n); static void findContinuousSequenceMethod4(int n); static void pickNum(int[] originArray, int n, int m, int[] selectArray, int startIndex, boolean inorder); static int binarySearch(int[] array, int key); static int findFirstEqual(int[] array, int key); static int findFirstEqualLarger(int[] array, int key); static int findFirstLarger(int[] array, int key); static int findLastEqual(int[] array, int key); static int findLastEqualSmaller(int[] array, int key); static List<Integer> shufflePump(List<Integer> origin); static List<Integer> shuffleSwap(List<Integer> origin); static int[] shuffleSwap(int[] origin); static String getAccurateDivide(int a, int b, int n); static Set<Integer> getPrimeNumInefficient(int range); static Set<Integer> getPrimeNumEfficient(int range); static int getIntervalDays(int year, int month, int day); static int pageHelper(int n, int m); static boolean isOdd(int num); }
DataUtil { public static int getMatrixHeavy(int[][] matrix, int m, int n) { int[][] dpArray = new int[m][n]; int sum = 0; for (int i = 0; i < m; i++) { sum += matrix[i][0]; dpArray[i][0] = sum; } sum = 0; for (int j = 0; j < n; j++) { sum += matrix[0][j]; dpArray[0][j] = sum; } for (int i = 1; i < m; i++) { for (int j = 1; j < n; j++) { dpArray[i][j] = matrix[i][j] + Math.max(dpArray[i - 1][j], dpArray[i][j - 1]); } } return dpArray[m - 1][n - 1]; }  static int getMatrixHeavy(int[][] matrix, int m, int n); static int maxSequenceSum(int[] array); static int fibonacciRecursive(int n); static int fibonacci(int n); static int findMaxUnContinuousSum(int[] array); static void findContinuousSequenceMethod1(int n); static void findContinuousSequenceMethod2(int n); static void findContinuousSequenceMethod3(int n); static void findContinuousSequenceMethod4(int n); static void pickNum(int[] originArray, int n, int m, int[] selectArray, int startIndex, boolean inorder); static int binarySearch(int[] array, int key); static int findFirstEqual(int[] array, int key); static int findFirstEqualLarger(int[] array, int key); static int findFirstLarger(int[] array, int key); static int findLastEqual(int[] array, int key); static int findLastEqualSmaller(int[] array, int key); static List<Integer> shufflePump(List<Integer> origin); static List<Integer> shuffleSwap(List<Integer> origin); static int[] shuffleSwap(int[] origin); static String getAccurateDivide(int a, int b, int n); static Set<Integer> getPrimeNumInefficient(int range); static Set<Integer> getPrimeNumEfficient(int range); static int getIntervalDays(int year, int month, int day); static int pageHelper(int n, int m); static boolean isOdd(int num);  }