LeetCode: Longest Substring Without Repeating Characters
Question: https://leetcode.com/problems/longest-substring-without-repeating-characters/
Solution: 1 Test Case Failed
Probable Solution, Need to remove the For loop
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
len_s = len(s)
max_sub = 0
for character in range(0,len_s):
for sub_character in range(character,len_s+1):
if len(set(s[character:sub_character])) == len(s[character:sub_character]) and len(s[character:sub_character]) > max_sub:
max_sub = len(s[character:sub_character])
return max_sub
Comments
Post a Comment