無重復字符的最長字符串問題,我這樣寫一直報錯
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'?
請問按照這個思路應該怎麼改?
[python (1), interview process 4 rounds of technical aspects +1 round of HR
adopt fetchall Methods to get
Interviewed 20k Python engineers and talked about these 26 questions, all of which are classics
Hello everyone, this is Progra
50 necessary Python interview questions (it is recommended to like them)
In the past 2021 year ,Python