[algogeeks] Re: Amazon Interview Question

2012-07-15 Thread santosh thota
For the series like 2,4,3,9,4,16,5,25 ur algo runs in o(n*n/2) =o(n^2) On Friday, 13 July 2012 13:16:50 UTC+5:30, jatin wrote: 1)Find product of the array and store it in say prod o(n) and o(1) 2)now traverse the array and check if static int i; tag: while(in) if( prod

[algogeeks] Re: Amazon Interview Question

2012-07-15 Thread santosh thota
If we can retrieve ith prime efficiently, we can do the following... 1.maintain a prod=1, start from 1st element, say a[0]=n find n th prime 2.check if (prod% (ith_prime * ith_prime )==0) then return i; else prod=prod*ith_prime; 3.repeat it till end On Thursday, 12 July 2012 10:55:02

[algogeeks] Re: Finding the repeated element

2012-07-15 Thread santosh thota(IITG)
Could u please tell me the way to find number repeated odd number of time using X-oR..?? On Sunday, 27 November 2011 00:49:59 UTC+5:30, Gene wrote: Isn't this overkill? If you're already using a set, just check the set before you insert each new element, and you'll discover the duplicates: