This is MS Q and hasing will give the right answer. walk over the string, if it is present in hashTable, it is first repeated character. This is single pass.
However, if you do another pass, your answer would be "a" which is "first char that is repeated" whereas "b" is first character to occur first again in the string. Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Fri, Jun 8, 2012 at 2:15 PM, himanshu kansal <himanshukansal...@gmail.com > wrote: > how can we find 1st repeating character in string??? > e.g. if the string is "abba" it should return 'b' and not 'a'..... > > note: hashing will give the answer as 'a'.... > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@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. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@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.