class LongestIncreasingSubsequence:
def getLIS(self, A, n):
# write code here
dp=[0 for i in range(n)]
dp[0]=1
max=0
print dp
for i in range(n):
now=0
if i!=0:
res=1
for j in range(i):
if A[i]>A[j]:
res=dp[j]
now=now +1
if now>=max:
max=now
dp[i]=res+1
else:
dp[i]=res
print dp
#return max(dp)
kk=LongestIncreasingSubsequence()
kk.getLIS([1,4,2,5,3],5)
其中dp 是一个以int类型为成员的list
而使用max()函数时却会报错
TypeError: 'int' object is not callable
是由什么原因导致的?
你的max函数在第五行被赋值成0了,max函数被覆盖了,你的变量改个名不要跟库函数重名了