Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def findSubString(self, s):
- v=set(s)
- l=0
- d={}
- need=len(v)
- n=len(s)
- ans=n+1
- have=0
- for r,rc in enumerate(s):
- d[rc]=d.get(rc,0)+1
- if d[rc]==1:have+=1
- while have==need:
- ans=min(ans,r-l+1)
- d[s[l]]-=1
- if d[s[l]]==0:
- d.pop(s[l])
- have-=1
- l+=1
- return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement