Updated 2 years ago
3. longest-substring-without-repeating-characters
Use the "Run" button to execute the code.
!pip install jovian --upgrade --quiet
import jovian
Given a string s, find the length of the longest substring without repeating characters.
Brute force solution:
- create empty list, counter sum, and result list
- iterate through each position in the string, then iterate through each char starting with index
- if the character is not in the list, add it and increase the counter by 1
- if it is in the list add the counter sum to the result list reset the counter sum and list to zero and nothing, add that char to list
- return the max of the result list