Re: [algogeeks] Re: longest interval

2010-11-03 Thread sumant hegde
, 2010 at 10:47 PM, Soumya Prasad Ukil wrote: > why not the answer (0,7)? > > On Nov 1, 4:02 pm, sumant hegde wrote: > > Say diff [i] = (no. of 1s in B[ 0...i ]) - (no. of 1s in A[0...i]). In > other > > words the subarray B(0,i) contains diff(i) no. of more 1s than the &g

Re: [algogeeks] longest interval

2010-11-01 Thread sumant hegde
g the segment A[0..2] (which too contained an extra 1, again by diff[2]=-1). On Mon, Nov 1, 2010 at 3:49 PM, sunny agrawal wrote: > @sumanth > can you plz post algorithm in short. > > On Mon, Nov 1, 2010 at 3:45 PM, sumant hegde wrote: > >> >> see attached file >> &

Re: [algogeeks] longest interval

2010-11-01 Thread sumant hegde
see attached file On Sun, Oct 31, 2010 at 4:27 PM, snehal jain wrote: > Find longest interval:- > 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

Re: [algogeeks] Google Question: Find kth largest of sum of elements in 2 array

2010-10-06 Thread sumant hegde
Correction: On Thu, Oct 7, 2010 at 11:12 AM, sumant hegde wrote: > If S(h)= a[p]+b[q] and S(i)= a[r]+b[s], then obviously p >= r and q>= s, > .. then p >= r and q <= s.. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks&

Re: [algogeeks] Google Question: Find kth largest of sum of elements in 2 array

2010-10-06 Thread sumant hegde
Let S(k) indicate the kth largest sum as per the question. We can also say that every S corresponds to a pair, (u,v) such that S=a[u]+b[v]. Now the idea is to keep track of two previous S's (in turn two pairs) such that one pair has the greatest 'u' of all so-far pairs. That is, this pair has most

Re: [algogeeks] Multiplication of two numbers

2010-09-19 Thread sumant hegde
Adding to the partial solution, if x, y are first digits, and x*y + x + y < 10, the result will be a+b -1 digits. "If not, u will need a complex logic to solve" On Mon, Sep 20, 2010 at 10:50 AM, rahul patil wrote: > A partial solution is , if you multiply first digits of two nos and > result

Re: [algogeeks] Re: Enumerate restricted knight walks

2010-08-19 Thread sumant hegde
Thanks. Can we find a closed form solution for that recurrence? On Thu, Aug 19, 2010 at 7:15 PM, Dave wrote: > Let f(m,n) be the number of walks in an m x n board that is a subset > of the M x N board. Then, for 2 <= m <= M and 2 <= n <= N, f satisfies > the following recurrence relationship. >

Re: [algogeeks] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-08-18 Thread sumant hegde
It is not clear whether 'subtraction' operation for given base B1 is granted defined or you should write code for it. If it is already defined, then simulating division (working wrt base B1) is easy (repeated subtraction). Then the normal procedure of converting a number from base 10 to base b2 wou