[algogeeks] Re: find duplicate and missing element

2010-09-02 Thread bittu
@luckyzoner can post the c program of what u ave said above.. -- 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

Re: [algogeeks] Re: find duplicate and missing element

2010-09-02 Thread ashish agarwal
In this method overflow will be there..if number is just bigger...so by doing XOR we can get missing number and repeated number . take xor of all element of array and take this xor with array[1...n] So we get xor of two numbers. now get set bit of this xor and proceed. On Thu, Sep 2, 2010 at

Re: [algogeeks] Re: Take 5 digit number and find 2 power that number.............

2010-09-02 Thread ashish agarwal
I think it will be 1x On Wed, Sep 1, 2010 at 10:53 PM, Yan Wang wangyanadam1...@gmail.com wrote: Maybe you misunderstand the question. The question is how to compute 2^X where 0 = X = 9? How? On Wed, Sep 1, 2010 at 10:48 PM, Ruturaj rutura...@gmail.com wrote: a 5 digit number is

Re: [algogeeks] Re: Take 5 digit number and find 2 power that number.............

2010-09-02 Thread saurabh singh
Suppose the number of shifts be x. Also let the integer be represented by 16 bits on that machine. Now take int n= (int)(x/16 + 0.5), to take the upper cap on result :) . SO having 2^x will be same as doing 2(x-1) so essentially if we represent the resultant number in a linked list of nodes, where

Re: [algogeeks] Re: Take 5 digit number and find 2 power that number.............

2010-09-02 Thread vikash jain
nice... -- 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

Re: [algogeeks] Re: find duplicate and missing element

2010-09-02 Thread vikash jain
@ashish: cud u plzz explain a bit more... -- 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.

Re: [algogeeks] Re: Take 5 digit number and find 2 power that number.............

2010-09-02 Thread prasad rao
can post the c program of what u ave said above On 2 September 2010 16:06, vikash jain vikash.ro...@gmail.com wrote: nice... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Re: find duplicate and missing element

2010-09-02 Thread Manjunath Manohar
this question can be sovled very easily 1.jus sum the given array...x 2.sum the squares of the given array..y 3.now use the AP.n(n+1)/2..for n=100 4.similarly compute n(n+1)(2n+1)/6 for n =100.. Now solve these eqns ...u get the missing and the dupicate.. -- You received this message

Re: [algogeeks] Re: Amazon intern Question

2010-09-02 Thread Manjunath Manohar
trie will be the best choice for this.. -- 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

Re: [algogeeks] Re: find duplicate and missing element

2010-09-02 Thread Ankit Sinha
@Dhritiman, It's good algo man!!!The only thing is we are destroying the array but also that's mandatory as only o(n) complexity we are interested in. As Somebody wanted the code, here I am attaching below: - int a[SIZE_A] = {0,2,1,4,0}; int i = 0, dup = 0, pos = 0, t =0;