Use an array of lentgh 26. for hashing from character a to z. Now we know that longest string can be of length 26 at most . So as you read a character , hash it . Now , maintain a counter count. Initialize it to 0 . Now start reading the string and start hashing. by making hash_array[ch-'a'] to 1 . (where hash_array is array used for hashing and ch is character read. If the character read is already Hashed , then that means ki Character is repeated . Make hash array as 0 for all the elements , set count to 0 again . Start hashing again . Check the maximum value of count reached .That is your Answer .
Time complexity : O(26*n) == O(n) . . . On Thu, Jul 21, 2011 at 9:09 PM, Abhi <abhi123khat...@gmail.com> wrote: > Given a string, find the length of the largest unique substring in it.. > > Sample Case > Input: "abcadece" > Output:5 (the string "bcade") > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/algogeeks/-/XkHOLozCtIIJ. > 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. > -- Ankur Khurana Computer Science Netaji Subhas Institute Of Technology Delhi. -- 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.