Skip to content

Commit d78b1b0

Browse files
Added Longest_Substring_Without_Repeating_Characters.py
Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: s = "pwwkew" Output: 3 Explanation: The answer is "wke", with the length of 3. Notice that the answer must be a substring, "pwke" is a subsequence and not a substring. Example 4: Input: s = "" Output: 0 Constraints: 0 <= s.length <= 5 * 104 s consists of English letters, digits, symbols and spaces.
1 parent 9bccf15 commit d78b1b0

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#https://www.facebook.com/ratnadeep.pragwalit/posts/2791088471172809
2+
#Subscribed by Ratnadeep Ghosh
3+
4+
s=input()
5+
m=0
6+
7+
s1=""
8+
j=0
9+
for i in range(len(s)):
10+
for j in range(i,len(s)):
11+
if s[j] not in s1:
12+
s1=s1+s[j]
13+
else:
14+
break
15+
m=max(m,len(s1))
16+
s1=""
17+
18+
print(m)

0 commit comments

Comments
 (0)