---
# System prepended metadata

title: "\n"

---

```python
from collections import Counter

# [1,1,2,3,4,1,1] [1,2,1,1,5] => [1,1,1,2]
# [1,1,1,1,1,1] [1,1,1,1,1,1]
def commonElements(list_1, list_2):
    #[l1, l2, l3]
    set_list = []
    for l in lists:
        set_list.append(set(l))
    
    # FInd intersection of all the sets
    
    
#     if not list_1 or not list_2:
#         return []
    
    
#     output = []
#     map_1 = Counter(list_1)
#     map_2 = Counter(list_2)  # {1: 4}
    
#     for key, freq1 in map_1.items():
#         if key in map_2:
#             freq2 = map_2[key]
#             minimum = min(freq2, freq1)
#             for i in range(minimum):
#                 output.append(key)
    
#     return output
            
    
#     seen = set()
#     for num in list_1:
#         seen.add(num)
#     output = []
#     for num in list_2:
#         if num in seen:
#             output.append(num)
    
#     return output

```

"""
Time O(n + m) n is len(l_1) and m is len(list_2)
Space Complecity: O(n)
"""


1 -> 10218 E park cir Boston MA USA
2 -> 1028 E park cir Boston MA USA
3 -> 1023 D park cir Boston MA USA

Orders: [order_id INT pk, ship_adr_id INT fk, billin_adr_id INT fk]


Address: [addr_id INT pk, street_no TEXT, unit TEXT, state_id INT fk, country_id INT fk]

Country: [country_id INT pk, name TEXT]

State: [state_id INT pk, state_name TEXT, country_id INT fk]

customer_has_address: [customer_id INT pk,  adress_id INT pk]

Country [(1, USA)]
State [(1, MA, 1)]
Order [(1, 3, 2), (2, 3, 2)]
Address [(1, 10218, E park, Boston 1, 1)]

