Re: [algogeeks] Constant time solution needed

2012-08-13 Thread Srividhya Sampath
compute the sum array by using this >>> formula >>> >>> sum[i][j] = sum[i-1][j-1] + (sum[i-1][j] - sum[i-1][j-1]) + (sum[i][j-1] >>> - sum[i-1][j-1])+ip[i][j] >>> [smaller rect] [that row sum value][that >>> c

Re: [algogeeks] Constant time solution needed

2012-08-12 Thread Srividhya Sampath
se it will be Ans = 18-0+0 = 18 > > Please lemme know if any bugs with the logic. > > > On Sun, Aug 12, 2012 at 6:27 PM, Srividhya Sampath > wrote: > >> >> @ Vicky >> >> Can yo explain with an illustration ? >> >> >> On Sat, Aug 11, 2

Re: [algogeeks] Constant time solution needed

2012-08-12 Thread Srividhya Sampath
@ Vicky Can yo explain with an illustration ? On Sat, Aug 11, 2012 at 10:07 PM, ~*~VICKY~*~ wrote: > May be you can consider creating a 2d array to pre process and store all > the rectangle sums as a dependent subproblem, the sum of larger rect will > be currValuesAdded+OldRectSum. So when you g

Re: [algogeeks] Constant time solution needed

2012-08-12 Thread Srividhya Sampath
say yo have 3*4 matrix... 0 1 2 3 4 5 6 7 8 9 10 11 if the co-ordinates are (0,0),(0,2),(1,0),(1,2) the o/p should be 0+1+2+4+5+6 On Sat, Aug 11, 2012 at 9:57 PM, adarsh kumar wrote: > Sum of the integers meaning? Do you mind giving an example test case? > > regards. > > On Sat, Aug 11, 2012