I m trying to have this result: [5,4,8]
but I m getting this: []
listA = [4,1,8,4,5]
listB = [5,6,1,8,4,5]
class Solution(object):
def getIntersectionNode(listA,listB):
de=[]
for i in range(-1,-len(listB)):
for j in range(-1,-len(listB)):
if listA[i] == listB[i]:de.append(listA[-1])
elif listA[-1] != listB[-1]: print("null")
return de
What is wrong with this code?