human
Length of the longest substring without repeating characters | Python3 program to find the length of the longest substring without repeating characters.
Result.
Note : Default values in visited are false.
If current character is visited Break the loop.
Else update the result if this window is larger , and mark current character as visited ..
Remove the first character of previous window.
Driver code"
How can the above be solved in Python?
 Can you provide a code to length of the longest substring without repeating characters and the other steps required?
assistant
#Here is code to length of the longest substring without repeating characters and the other steps required.
 def longestUniqueSubsttr ( str ) :
	n = len ( str )
	res = 0
	for i in range ( n ) :
		visited = [ 0 ] * 256
		for j in range ( i , n ) :
			if ( visited [ ord ( str [ j ] ) ] == True ) :
				break
			else :
				res = max ( res , j - i + 1 )
				visited [ ord ( str [ j ] ) ] = True
		visited [ ord ( str [ i ] ) ] = False
	return res
str = " geeksforgeeks "
print ( " The ▁ input ▁ is ▁ " , str )
len = longestUniqueSubsttr ( str )
print ( " The ▁ length ▁ of ▁ the ▁ longest ▁ " " non - repeating ▁ character ▁ substring ▁ is ▁ " , len )