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 <anandut2...@gmail.com> 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 > <ravindra.it...@gmail.com>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 < >> manjunath.n...@gmail.com> 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 algoge...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> >>> . >>> 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 algoge...@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> >> . >> 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 algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> > . > 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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.