Time complexity of checking whether a set is contained in another set
问题 I am trying to implement the example of finding the shortest substring of a given string s containing the pattern char . My code is working fine, but my goal is to attain the time complexity of O(N) where N is length of s . Here is my code; def shortest_subtstring(s,char): #smallest substring containing char.use sliding window start=0 d=defaultdict(int) minimum=9999 for i in range(len(s)): d[s[i]]+=1 #check whether all the characters from char has been visited. while set(char).issubset(set([j