human
Length of the longest substring without repeating characters | This functionr eturns true if all characters in strr [ i . . j ] are distinct , otherwise returns false.
Note : Default values in visited are false.
Returns length of the longest substring with all distinct characters ..
Result.
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 areDistinct ( strr , i , j ) :
	visited = [ 0 ] * ( 26 )
	for k in range ( i , j + 1 ) :
		if ( visited [ ord ( strr [ k ] ) - ord ( ' a ' ) ] == True ) :
			return False
		visited [ ord ( strr [ k ] ) - ord ( ' a ' ) ] = True
	return True
def longestUniqueSubsttr ( strr ) :
	n = len ( strr )
	res = 0
	for i in range ( n ) :
		for j in range ( i , n ) :
			if ( areDistinct ( strr , i , j ) ) :
				res = max ( res , j - i + 1 )
	return res
if __name__ == ' _ _ main _ _ ' :
	strr = " geeksforgeeks "
	print ( " The ▁ input ▁ is ▁ " , strr )
	len = longestUniqueSubsttr ( strr )
	print ( " The ▁ length ▁ of ▁ the ▁ longest ▁ " " non - repeating ▁ character ▁ substring ▁ is ▁ " , len )