Skip to content

Commit ad3c3be

Browse files
add 3 go
1 parent 735c827 commit ad3c3be

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LeetCode
66
|---| ----- | -------- | ---------- | ---------- | ---------- | ---------- | ---------- |
77
|0001|[Two Sum](https://leetcode.com/problems/two-sum/) | [c](./src/0001-Two-Sum/two_sum.c) | [c++](./src/0001-Two-Sum/two_sum.cpp) |[python](./src/0001-Two-Sum/two_sum.py)|[go](./src/0001-Two-Sum/two_sum.go)|rust|Easy|
88
|0002|[Add Two Numbers](https://leetcode.com/problems/add-two-numbers/) | [c](./src/0002-Add-Two-Numbers/Add_Two_Numbers.c) | [c++](./src/0002-Add-Two-Numbers/Add_Two_Numbers.cpp) |[python](./src/0002-Add-Two-Numbers/Add_Two_Numbers.py)|[go](./src/0002-Add-Two-Numbers/Add_Two_Numbers.go)|[rust]()|Medium|
9-
|0003|[Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/) | c | [c++](./src/0003-Longest-Substring-Without-Repeating-Characters/0003.cpp) |[python](./src/0003-Longest-Substring-Without-Repeating-Characters/0003.py)|||Medium|
9+
|0003|[Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/) | c | [c++](./src/0003-Longest-Substring-Without-Repeating-Characters/0003.cpp) |[python](./src/0003-Longest-Substring-Without-Repeating-Characters/0003.py)|[go](./src/0003-Longest-Substring-Without-Repeating-Characters/0003.go)||Medium|
1010
|0004|[Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays/) | c | [c++](./src/0004-Median-of-Two-Sorted-Arrays/0004.cpp) |[python](./src/0004-Median-of-Two-Sorted-Arrays/0004.py)|||Hard|
1111
|0005|[Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring/) | c | [c++](./src/0005-Longest-Palindromic-Substring/0005.cpp) |[python](./src/0005-Longest-Palindromic-Substring/0005.py)|||Medium|
1212
|0006|[ZigZag Conversion](https://leetcode.com/problems/zigzag-conversion/) | c | [c++](./src/0006-ZigZag-Conversion/0006.cpp) |[python](./src/0006-ZigZag-Conversion/0006.py)|||Medium|
@@ -421,4 +421,5 @@ LeetCode
421421
|1086|[High Five](https://leetcode.com/contest/biweekly-contest-2/problems/high-five/) | c | [c++](./src/1086-High-Five/1086.cpp) |[python](./src/1086-High-Five/1086.py)|||Easy|
422422
|1087|[Brace Expansion](https://leetcode.com/contest/biweekly-contest-2/problems/brace-expansion/) | c | [c++](./src/1087-Brace-Expansion/1087.cpp) |[python](./src/1087-Brace-Expansion/1087.py)|||Medium|
423423
|1089|[Duplicate Zeros](https://leetcode.com/problems/duplicate-zeros/) | c | [c++](./src/1089-Duplicate-Zeros/1089.cpp) |[python](./src/1089-Duplicate-Zeros/1089.py)|||Easy|
424-
|1090|[Largest Values From Labels](https://leetcode.com/problems/largest-values-from-labels/) | c | [c++](./src/1090-Largest-Values-From-Labels/1090.cpp) |[python](./src/1090-Largest-Values-From-Labels/1090.py)|||Medium|
424+
|1090|[Largest Values From Labels](https://leetcode.com/problems/largest-values-from-labels/) | c | [c++](./src/1090-Largest-Values-From-Labels/1090.cpp) |[python](./src/1090-Largest-Values-From-Labels/1090.py)|||Medium|
425+
|1091|[Shortest Path in Binary Matrix](https://leetcode.com/problems/shortest-path-in-binary-matrix/) | c | [c++](./src/1091-Shortest-Path-in-Binary-Matrix/1091.cpp) |[python](./src/1091-Shortest-Path-in-Binary-Matrix/1091.py)|||Medium|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
func lengthOfLongestSubstring(s string) int {
2+
dict := make(map[byte]int)
3+
res, l := 0, 0
4+
for i, ch := range []byte(s) {
5+
if _, ok := dict[ch]; ok && l <= dict[ch] {
6+
l = dict[ch] + 1
7+
}
8+
if i - l + 1 > res {
9+
res = i - l + 1
10+
}
11+
dict[ch] = i
12+
}
13+
return res
14+
}

0 commit comments

Comments
 (0)