human
Length of the longest substring without repeating characters | Creating a set to store the last positions of occurrence.
starting the initial point of window to index 0.
Checking if we have already seen the element or not.
If we have seen the number , move the start pointer to position after the last occurrence.
Updating the last seen value of the character.
Driver Code"
Solution in Python:
assistant
#Here is code to length of the longest substring without repeating characters and the other steps required.
 def longestUniqueSubsttr ( string ) :
	seen = { }
	maximum_length = 0
	start = 0
	for end in range ( len ( string ) ) :
		if string [ end ] in seen :
			start = max ( start , seen [ string [ end ] ] + 1 )
		seen [ string [ end ] ] = end
		maximum_length = max ( maximum_length , end - start + 1 )
	return maximum_length
string = " geeksforgeeks "
print ( " The ▁ input ▁ string ▁ is " , string )
length = longestUniqueSubsttr ( string )
print ( " The ▁ length ▁ of ▁ the ▁ longest ▁ non - repeating ▁ character ▁ substring ▁ is " , length )