leedcode刷题笔记
作者:互联网
算法竞赛结束后好久不刷题了
以后打算每天都写1-2
题
func max(x,y int) int{
if x<y{
return y
}else{
return x
}
}
func lengthOfLongestSubstring(s string) int {
mp := map[byte]int{}
n := len(s)
rk,ans := -1,0
for i:=0;i<n;i++{
if i!=0{
delete( mp,s[i-1] )
}
for rk+1<n && mp[s[rk+1]] == 0{
mp[s[rk+1]]++
rk++
}
ans = max( ans,rk-i+1 )
}
return ans
}
标签:return,int,max,leedcode,笔记,mp,ans,刷题,rk 来源: https://blog.csdn.net/jziwjxjd/article/details/122271183