Intersection of lists (PYTHON)

 n1 = int(input("Enter the size of list 1 : "))

l1 = [int(input("enter the elements : ")) for i in range(n1)]
n2 = int(input("Enter the size of list 2 : "))
l2 = [int(input("enter the elements : ")) for i in range(n2)]
l3 = []
for i in range(n1):
    if l1[i] not in l3 and l1[i] in l2:
        l3.append(l1[i])
for i in range(n2):
    if l2[i] not in l3 and l2[i] in l1:
        l3.append(l2[i])
print(l3)

Comments

Popular posts from this blog

First_Come_First_Serve CPU Scheduling

Reversing stack Method 2 !! (One Helper Stack only)

Populating Next Right Pointers in Each Node in O(1) space (without queue and level order)

Calculate factorial of large numbers !! (Using Arrays)

Multiplication of large numbers (Given in string format)

Left View of Binary Tree (Method 1 using recursion)

Check Bracket Sequence

Image Multiplication

Boundary Traversal of binary tree

BST to greater sum tree