Skip to content

Commit 332e04e

Browse files
committed
Add Solution.py for 0003.Longest Substring Without Repeating Characters
1 parent 0a79699 commit 332e04e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def lengthOfLongestSubstring(self, s: str):
3+
max = 0
4+
length = len(s)
5+
substr = ""
6+
for i in range(0, length):
7+
index = substr.find(s[i])
8+
if index > -1:
9+
substr = substr[index + 1:]
10+
substr += s[i]
11+
max = (max if (max > len(substr)) else len(substr))
12+
return max

solution/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
│   ├── README.md
2626
│   ├── Solution.go
2727
│   ├── Solution.java
28-
│   └── Solution.js
28+
│   ├── Solution.js
29+
│   └── Solution.py
2930
├── 0004.Median of Two Sorted Arrays
3031
│   ├── README.md
3132
│   ├── Solution.cpp

0 commit comments

Comments
 (0)