"abba" as goel pointed out.. is the answer 'b' or 'a' .. ie does the order in which u encounter the character matters.. 'a' comes before 'b' here...
if it is 'b' then a normal buf[txt[i]-'a']++ should do.. :) On Wed, Jun 8, 2011 at 8:48 AM, Shivaji Varma <[email protected]> wrote: > This problem of finding first non-repeating element in an array is > different from finding the first non-repeating character in a string. The > latter is a pretty easy one. > > > On Wed, Jun 8, 2011 at 12:12 AM, Anand <[email protected]> wrote: > >> >> http://anandtechblog.blogspot.com/2011/06/first-repeating-character-in-string.html >> >> >> On Tue, Jun 7, 2011 at 9:30 AM, Apoorve Mohan <[email protected]>wrote: >> >>> if there is no space complexity constraint then *hashing* can be used i >>> guess >>> >>> >>> On Tue, Jun 7, 2011 at 9:57 PM, Ashish Goel <[email protected]> wrote: >>> >>>> "abba" >>>> >>>> >>>> what will be first repeated element? >>>> >>>> >>>> >>>> Best Regards >>>> Ashish Goel >>>> "Think positive and find fuel in failure" >>>> +919985813081 >>>> +919966006652 >>>> >>>> >>>> >>>> On Tue, Jun 7, 2011 at 12:06 AM, the coder <[email protected]>wrote: >>>> >>>>> can we find the first repeated element in array in O(N) complexity. >>>>> Array may contain more than 1 repeated elements. >>>>> >>>>> -- >>>>> 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. >>>>> >>>>> >>>> -- >>>> 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. >>>> >>> >>> >>> >>> -- >>> 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. >>> >> >> -- >> 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. >> > > -- > 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. > -- 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.
