sorry, for the previous post, consider this... iterate the string using variable i 'low' is another variable that stores the index of previous occurrence of the character+1 initially, i=0 , low=0 max=i-low
"abcdedepoiuytu" hashtable : a= -1 , b= -1, . . . z = -1 a=0 b=1 c=2 d=3 e=4 now, d comes for the second time.. index value is 5 this time..it check with the hash table..value there is a non negative no.(3) max= i-low = 5-0=5 low= previous occurence of d+1(3+1=4), so low=4 value at d in hashtable is now=5 a=0 b=1 c=2 d=5 e=4 changes to e=6 i-low<max..so dont change max low=previous value for 'e' +1 =5 max=5 move further like this.. in the end, check (i-low) once again...compare with max..it will give 8 in this case. the point is, as soon as a repetition occurs, u have to change 'low' to the most recently repeated character's previous index+1.. and change max if i-low>max. plz check if this works, and if it doesn't..plz give the input for which it fails. -- 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.