Program - Given a string, find the length of the longest substring without repeating characters.


Topic: Program - Given a string, find the length of the longest substring without repeating characters.

Solution

str = "IshwarVenugopal"
def longest_non_repeat(str):   
    i=0
    max_length = 1
    for i,c in enumerate(str):       
        start_at = i
        sub_str=[]         
        while (start_at < len(str)) and (str[start_at] not in sub_str):
            sub_str.append(str[start_at])
            start_at = start_at + 1
            
        if len(sub_str) > max_length:
            max_length = len(sub_str)
        print(sub_str)
        
    return max_length
longest_non_repeat(str)



List all Python Programs