Re: [algogeeks] Re: Valid Array

2010-12-10 Thread fenghuang
@mohan, when the num of repeatation is bigger than 1, it may be wrong,please check {1, 1, 2, 5, 6, 6} On Fri, Dec 10, 2010 at 12:41 PM, mo...@ismu mohan...@gmail.com wrote: i did nt get this xor part in adithya solution check if this works array is valid if satisfy 2 conditions

[algogeeks] Re: Valid Array

2010-12-09 Thread Prims
I got the correct answer: If it is a valid array, sum of all elements in the array = value calculated using arithmetic progression formula In this case Sum of arithmetic progression = (n/2)[2*a+(n-1)*d} where a = min of the array n = number of elements d = 1 If this value is equal to sum of

Re: [algogeeks] Re: Valid Array

2010-12-09 Thread mo...@ismu
prims check for this case [1,1,4,4] -- 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

[algogeeks] Re: Valid Array

2010-12-09 Thread Prims
my bad The solution i quoted works only in case of no repititions. Aditya solution is correct On Dec 10, 9:23 am, mo...@ismu mohan...@gmail.com wrote: prims  check for this case  [1,1,4,4] -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] Re: Valid Array

2010-12-09 Thread mo...@ismu
i did nt get this xor part in adithya solution check if this works array is valid if satisfy 2 conditions 1.max-min=n-1 2.there should be no repeatations first one can be done in O(n) for second check 1xor2xor...xorn=(a[1]-min+1)xor(a[2]-min+1)xor.. if both are equal there are