Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

longest substring without repeating characters python

str = "AABBCDEFABC"		#string to check
i =0
j = 0
d={}					
sub_str_len = 0
while j < len(str):	#checks every character of the string
  if str[j] not in d or i>d[str[j]]:
    sub_str_len = max(sub_str_len,(j-i+1))
    d[str[j]] = j
  else:
    i = d[str[j]]+1
    sub_str_len = max(sub_str_len,(j-i+1))
    j-=1

  j+=1
    
print(sub_str_len)		#prints the size
    
Comment

PREVIOUS NEXT
Code Example
Python :: rotational list python 
Python :: python añadir elementos a una lista 
Python :: convert 2d list to 1d python 
Python :: segregate list in even and odd numbers python 
Python :: how to filter mask results in python cv2 
Python :: new event loop asyncio 
Python :: greeper 
Python :: how to change the rate of speech in pyttsx3 
Python :: python in line conditional statement 
Python :: pandas merge dataframes from a list 
Python :: python -m pip install 
Python :: django session expire time 
Python :: python set current working directory to script location python 
Python :: How to normalize the data to get to the same range in python pandas 
Python :: create spark dataframe in python 
Python :: python how to get directory of script 
Python :: create np nan array 
Python :: make beep python 
Python :: python system of equations 
Python :: schedule asyncio python 
Python :: ec2 upgrade python 3.7 to 3.8 
Python :: python get object attribute by string 
Python :: How to Create a Pie Chart in Seaborn 
Python :: random string generator python 
Python :: how to insert a variable into a string without breaking up the string in python 
Python :: plot confidence interval matplotlib 
Python :: godot string format 
Python :: django staff required 
Python :: sort array python by column 
Python :: how to subtract dates in python 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =