Re: [algogeeks] Re: Single linked list questions.

2011-01-06 Thread vishal raja
@sourabh, In addition to your solution, If there is any cycle(loop) exist in the link list your algo will fail. To solve this problem first detect this cycle if there is any and count the element in the cycle, and then you can do the mathematics. On Thu, Jan 6, 2011 at 6:51 PM, sourabh jakhar

Re: [algogeeks] Re: Single linked list questions.

2011-01-06 Thread vishal raja
a Y-shaped structure On Thu, Jan 6, 2011 at 7:29 PM, vishal raja vishal.ge...@gmail.comwrote: @sourabh, In addition to your solution, If there is any cycle(loop) exist in the link list your algo will fail. To solve this problem first detect this cycle if there is any and count

Re: [algogeeks] Re: combinations problem

2010-12-29 Thread vishal raja
@juver, ofcourse , and that's not a big deal. On Wed, Dec 29, 2010 at 5:11 PM, juver++ avpostni...@gmail.com wrote: Yes, it's true. But we should process DP in the following order not to take one element more than once. -- You received this message because you are subscribed to the Google

Re: [algogeeks] Divide an array into two equal subsets

2010-12-29 Thread vishal raja
] = count[i-1][j] if P(i-1,j) ==1 count[i][j] = count[i-1][j-a[i]] if P(i-1,j-a[i]) ==1 else count[i][j] = 0 On Thu, Dec 30, 2010 at 11:42 AM, vishal raja vishal.ge...@gmail.comwrote: yeah, My bad. Missed that. On Wed, Dec 29, 2010 at 10:52 PM, Wladimir

Re: [algogeeks] Answer This

2010-12-17 Thread vishal raja
There were 20 green eyed people and they will commit suicide on 20th day altogether. See, There is atleast one green-eyed man. So let's take the case if there was only one gree-eyed man. than that man could've seen the colour of all other blued-eyed people and commit suicide on the very first day.

Re: [algogeeks] Arrays

2010-09-20 Thread vishal raja
add up all the elements in array A say sumA and array B say sumB ,substract the sumA from sumB... You'll get the element. On Tue, Sep 21, 2010 at 5:36 AM, Anand anandut2...@gmail.com wrote: Two unsorted arrays are given A[n] and B[n+1]. Array A contains n integers and B contains n+1 integers

Re: [algogeeks] Yahoo!!!! Puzzle

2010-09-14 Thread vishal raja
take out that one A pill that's there in the jar. take the half of all the four pills, that's how u'll make sure that u've had 1 of 'A' and 1 of 'B' pill. On Tue, Sep 14, 2010 at 2:52 PM, bittu shashank7andr...@gmail.com wrote: You are on a strict medical regimen that requires you to take two