u can set C = A - B, i.e. c[i] = A[i] - B[i] for all 0 <= i < N; then find out (p,q) such that C[p]+C[p+1]+...+C[q-1]+C[q] is zero.
On Sat, Dec 4, 2010 at 11:39 PM, Prims <topcode...@gmail.com> wrote: > We are given with two arrays A and B..each of size > N...elements of array contains either 1 or 0... > we have to find such an interval (p,q)(inclusive) such that the sum of > all > the elements of A (between this interval) and sum of all elements of > B > (between this interval ) is equal... > i.e. > a[p]+a[p+1]....+a[q]= b[p]+b[p+1]....+b[[q]q > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@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.