0

What is the difference between list initialization

dp = [[-1]*(target+2)]*(n+1)    and        
dp = [[-1] * (target+2) for _ in range(n+1)] 

On printing the output and type directly on ideone online ide i am getting same result .But if i am using these two in dp question on leetcode i am getting different output here is the code with output on ideone can some one explain the difference ?

0 Answers0