無重復字符的最長字符串問題,我這樣寫一直報錯
class Solution():
def lengthOfLongestSubstring(self,s):
m=str(s)
q=[]
max_1=0
for i in m:
if i not in q:
q.append(i)
print(q)
else:
sum_1=len(q)
q.clear()
q.append(i)
if max_1<sum_1:
max_1=sum_1
print(max_1)
s1=Solution("abcabcab")
si.lengthOfLongestSubstring()
報錯:TypeError: Solution() takes no arguments
然後我改成:s1=Solution()
si.lengthOfLongestSubstring("abcabcab")
又報錯:NameError: name 'si' is not defined. Did you mean: 's1'?
請問按照這個思路應該怎麼改?
adopt fetchall Methods to get
Hello everyone, this is Progra
In the past 2021 year ,Python