how about using hashing??? at the first collision we will know the repeated element....
worst case time here will be ( n/2 +1 ) On Fri, Aug 6, 2010 at 12:04 AM, Anand <[email protected]> wrote: > http://codepad.org/8eDVyeBT > > Using XOR logic we can find Duplicates in O(n) > > > On Thu, Aug 5, 2010 at 11:25 AM, ravindra patel > <[email protected]>wrote: > >> Your test case is wrong. With this pattern you can have at max n/3 >> occurrences of 1. The questions says that repeated element has n/2 >> occurrences >> >> >> On Thu, Aug 5, 2010 at 8:37 PM, Manjunath Manohar < >> [email protected]> wrote: >> >>> consider the test case of... >>> >>> 1 2 3 1... >>> >>> 1 repeated n/2 times and 2,3 are distinct n/2 elements >>> >>> for this the algo will not work >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]<algogeeks%[email protected]> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<algogeeks%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<algogeeks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- regards Apoorve Mohan -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
