👻 See our latest reviews to choose the best laptop for Machine Learning and Deep learning tasks!
Input: arr = [[1,2,3,4], [8,7,3,2], [9,2,6,3], [5, 1,2,3]] Output: Common Elements = [2,3]
We can quickly solve this problem in python with the intersection_update () Set () data structures .
How does intersection_update () work? p>
Suppose we have two sets A and B, then operation A.intersection_update (B) updates set A with common elements in sets A and B. For example, A = set ([1,2,3]) and B = set ([4,2,3]) now after accepting A.intersection_update (B) , the value of set A will be [2,3]. Syntax anySet.intersection_update (iterable) .
Common Elements = [2,3]
This article is courtesy of Shashank Mishra (Gullu) . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you’d like to share more information on the topic discussed above.
👻 Read also: what is the best laptop for engineering students in 2022?