I am a rookie working with algorithms and especially implementing them. Im trying to implement the brute force method using the prefix sum of the NxN-array I got this piece of code, in which i want to return the sum of maximum subarray.
prefix sum means that the array {{2, -1},{4, 19}} becomes {{2, 1},{6, 24}} // The prefix sum of the array is now stored in row tempmax=0; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { for(int k=0;k<i;k++) { for(int l=0;l<j;l++) { /** Brute forcing all combinations of subarrays using the prefix sum array * and check if the sum is bigger than max */ tempmax=row[i][j]-row[i][l]-row[k][j]+row[k][l]; max = Math.max(tempmax, max); } } } } return max; } Please help me modify the code so max contains the correct value. I have used this paper as inpiration the above code should be the same as the one at page 11. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.