Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func lengthOfLongestSubstring(s string) int {
- l:=0
- res:=0
- set:=map[byte]bool{}
- for r,_:= range s {
- _,f:=set[s[r]]
- for f {
- delete(set,s[l])
- l++
- _,f=set[s[r]]
- }
- set[s[r]] = true
- res = max(res,r - l + 1)
- }
- return res
- }
- func max(l,r int) int {
- if l > r {
- return l
- }
- return r
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement