# lengthy explanation give more attention #here we are finding sums on all valid partition and storing all four possible sums in variable a,b,c,d and and for all possible a,b,c,d we will keep runninf max and min/ lets take an example parttion is done at row=0, coloumn=1 00 01| 02 03 --------|--------- 10 11| 12 13 20 21| 21 22 a=arr[0][0]+arr[0][1] b=arr[0][2]+arr[0][3] c=arr[1][0]+arr[1][1]+arr[2][0][2][1] d=arr[1][2]+arr[1][3]+arr[2][1]+arr[2][2]; this can be coded like this
int a,b,c,d,max,main; a=b=c=d=max=min=0; for(int row=0;row++;row<n-1) for(int col=0;col++;col<n-1) { for(int i=0;i<=row;i++) { for(int j=0;j<=col;j++) a+=arr[i][j]; for(int j=col;j<=n-1;j++) b+=arr[i][j]; } for(int i=row+1;i<=n-1;i++) { for(int j=0;j<=col;j++) c+=arr[i][j]; for(int j=col;j<=n-1;j++) d+=arr[i][j]; } max=maximum(max,maximum(maximum(a,b),maximum(c,d))); //maximum(a,b) is predefined function to find maximum of two nos. min=minimum(min,minimum(minimum(a,b),minimum(c,d))); } cout<<"max:"<<max; cout<<"min:"<<min; } please check it and let me know if any m On Thursday, August 16, 2012 2:09:20 PM UTC+5:30, g4ur4v wrote: > > @sahil Can you please explain your question with an example ? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/COUmpAUCe20J. 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.