Re: [algogeeks] Re: find the integer

2011-07-09 Thread saurabh singh
Sort and take window of 2 while traversing, stop when the elements in the window do not match.The first one will be the non-repeated assuming only one such number exist in the array. complexity:o(nlogn) PS:Another possible solution is = 1. Form a BST.Add extra variable count to the node. 2.while

Re: [algogeeks] Re: find the integer

2011-07-09 Thread saurabh singh
code for my *second *solution http://www.ideone.com/oxDql http://www.ideone.com/oxDqlPoint out any bugs if you find. On Sat, Jul 9, 2011 at 12:43 PM, saurabh singh saurab...@gmail.com wrote: Sort and take window of 2 while traversing, stop when the elements in the window do not match.The

Re: [algogeeks] Re: find the integer

2011-07-09 Thread John Hayes
@saurabh.shouldn't be 5 also be in the outputi think u forgot to print the root value On Sat, Jul 9, 2011 at 9:27 PM, saurabh singh saurab...@gmail.com wrote: code for my *second *solution http://www.ideone.com/oxDql http://www.ideone.com/oxDqlPoint out any bugs if you find. On

Re: [algogeeks] Re: find the integer

2011-07-09 Thread saurabh singh
@John 5 is the number of inputs that the program will be expecting.Its not part of the array. On Sat, Jul 9, 2011 at 9:35 PM, John Hayes agressiveha...@gmail.com wrote: @saurabh.shouldn't be 5 also be in the outputi think u forgot to print the root value On Sat, Jul 9, 2011 at 9:27

[algogeeks] Re: find the integer

2011-07-08 Thread Gaurav Tyagi
Are their any space or time constraints ? On Jul 8, 3:21 pm, Piyush Sinha ecstasy.piy...@gmail.com wrote: is there anyting special about the array??? or it is aribitary array?? On 7/8/11, Dumanshu duman...@gmail.com wrote: given an array of intergers. find the any integer that occurs only

[algogeeks] Re: find the integer

2011-07-08 Thread Dumanshu
no constraints but try to give the optimized solution and plz no hashing. On Jul 8, 7:02 pm, Dumanshu duman...@gmail.com wrote: given an array of intergers. find the any integer that occurs only once. Others might occur any no. of times. -- You received this message because you are

Re: [algogeeks] Re: find the integer

2011-07-08 Thread Piyush Sinha
try sorting then if hashing On 7/8/11, Dumanshu duman...@gmail.com wrote: no constraints but try to give the optimized solution and plz no hashing. On Jul 8, 7:02 pm, Dumanshu duman...@gmail.com wrote: given an array of intergers. find the any integer that occurs only once. Others

Re: [algogeeks] Re: find the integer

2011-07-08 Thread raj singh
my solution solve the problem in O(n) time but requre space comlexty n. solution: 1. take an temp array and initialize it elements with zero; int temp[n]={0}; 2.increment the count of the element of temp which is appear when loop through the given array say a[n]; for(int i=0;in;i++)

Re: [algogeeks] Re: find the integer

2011-07-08 Thread Nitish Garg
Well your method can solve this problem when the range of the array elements is given. Try considering 2*10^9 as one of the element of the array, how big your temp array be? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this

Re: [algogeeks] Re: find the integer

2011-07-08 Thread Yogesh Yadav
a[]={2,2,3,3,3,4,4,5,6,6,7} size of array = n if not sorted than sort for(i=1;in-1;i++) //check for elements with index 1 to n-2 { if(a[i]!=a[i-1] a[i]!=a[i+1]) print(a[i]); } //now check for index 0 and n-1 if(a[0]!=a[1]) print(a[0]); if(a[n-1]!=a[n-2])