get common elements from two lists

Solutions on MaxInterview for get common elements from two lists by the best coders in the world

showing results for - "get common elements from two lists"
Gabriel
21 Nov 2017
1list1 = [1,2,3,4,5,6]
2list2 = [3, 5, 7, 9]
3list(set(list1).intersection(list2))
Christian
03 Apr 2019
1List<Integer> l1 = new ArrayList<Integer>();
2
3l1.add(1);
4l1.add(2);
5l1.add(3);
6
7List<Integer> l2= new ArrayList<Integer>();
8l2.add(4);
9l2.add(2);
10l2.add(3);
11
12System.out.println("l1 == "+l1);
13System.out.println("l2 == "+l2);
14
15List<Integer> l3 = new ArrayList<Integer>(l2);
16l3.retainAll(l1);
17
18    System.out.println("l3 == "+l3);
queries leading to this page
python program to find common items in two arrayscheck if two lists have a common element pythonpython get common elements in two arraysget common value sin two listshow to find common elemment in lists in pythonpython find common elements in two listsfind common elements in 2 lists of strings pythonpython find common vals from 2 lists find non common elements in two lists pythoncommon elements in list of list pythonpython percentage of common items in two listspython list find common elements from multi multidimensional listcommon elements between two lists pythonlists of common elements 2 list pythonfind common elements in multiple lists pythonfind common in two list pythonpython compare two lists get number of common elementspython common elements in multiple listsfind common elements in one list pythonfind common of two lists pythonfind common elements in three lists pythonpython common elements in two listsget common values from two lists but not in another list in pythonthe elements in which are common in both lists inpythoncommon elements in multiple list pythoncheck common elements in two lists pythonpython get common values from 2 listsreturn common elements of two arrays pythoncommon element in two list pythonfind common between two lists pythonfind common elements in two lists pythonget common elements from two lists pythonfind common elements in a list with their index pythonpython compare two lists for common elementslist take common of two listfind number of common elements in two lists pythonwrite a python program to find common items from two listshow to find common elements in 2 lists pythonfind common values in two lists pythoncommon elements from two lists pythonhow to get the common elements of a list in pythonfind items common in 2 listsstfind common elements between two lists pythoncommon elements in list pythonpython number of common elements in two listscommon items in 2 lists pythonfind common items two listshow to find common elements in two arrays pythoncommon elements in mutliple listscomparing lists to find common elements pythomcommon elements in lists pythonfind the common elements in two lists pythonprint non common elements in two lists pythonfind common elements in n list pythonpython how to find elements common to multiple listscommon elements in 2 listsfind common elements in 2 arrays pythonfind frequency of common elements in 2 lists pythoncheck if two lists have any common elements pythonfind common string in multiple lists pythoncompare two lists and get common elements pythonpython find first common element in two listsfind common elements in 2 lists of stringspythonfind common values in two list pythonfind common elements in two lists python and duplicateshow to print common elements between two list in pythonpython common element in two listschoose common elements from 2 liststaking common element from two listfind common str elements in two list pythonfind common elements in lists pythonpython check for common elements in the same listpython display non common elements between 2 listspython check for common elements in listscount common elements in two lists pythonfind common string in two list pythonfind common element in n number of list pythonfind common elements between two list pythonpython find common items from two lists2 29 find the common elements from 3 lists how to get common elements from two lists in pythonsee if 2 lists have a common element pythonhow to find out common things from two lists pythonfind common values between two lists pythonfind the common elements of 2 lists in djangohow to find common elements in two listsfind common items between two lists of dict pythoncheck all common iterms in two lists pythonpython common elements in 2 arrayspython get common elements in two listshow to find common elements among multiple listscheck common elemnets in two arrays pythnofind common values between lists pythonhow to find common terms between 2 lists pythonhow to know the common elemtns on two list on pyhtonnumber of common elements in two lists pythonpython combine two lists and find common elementshow to find the common elements in two lists in pythoncommon values between 2 lists pythonhow to all common value of two list in pythonpython common elements between listpython check two lists at least on common elementhow to find non common elements in two lists pythonhow to find common elements in a list in pythonwe have given two lists in python find the common elementshow to find every list with common elementsfind first common element in two listshow to get the common element of two lists with different sizes pythonpython find common items in two listsfinding common value between two list pythonhow many time the common element is present in both the lists pythonfind common elements in 2 list pythonhow to find common elements between n lists in pythonfind common strings in two lists pythonnon common elements in two lists pythonhow to find common elements in nested list pythonnot common elements in two lists pythonhow to find how many common elements in two lists pythonfind common element in two different listshow to find number of common elements of two lists pythoncheck common elements between two lists pythonget common element from two listscheck how many common values two lists have python how to list out common elements of two lists pythonfind common elements in multiple lists python without using setspython lists common elementscommon items in two lists pythonfind common elements in two arrays pythonhow to check if two lists have common elements pythonhow to find common elements in two lists pythonhow to find common elements in two lists in pythonhow to find the common elements of a list i pythoncommon items between two lists pythonhow to get common elements from two lists in python in orderfind common elements in two list pythonget common elements from two listspython program to check common elements in two listspandas find common elements in two listscheck for common elements between two listshow to find common elements in two arrays in pythoncommon elements in two arrays pythonhow to find common elements in 3 lists pythoncommon between 2 lists pythontwo list common element in pythonhow to find common elements in two or more lists pythonhow to find common elements in two large lists pythoncommon number between two list pythonfind common item in two list pythoncommon values in 2 lists pythonhow do i find a common element in two list in pythoncommon in two list pythonhow to find common items in two lists pythonno of common elements between lists pythonfinding common value between two list python numpyfinding common elements in two lists pythonhow to find common elemment in multiple lists in pythoncheck if two lists have common elements pythonfind common elements in a listpython get two list common elementspython find index of common elements in two listspython program to find common elements in two listsfind common elements in multiple lists python without using any functionfind common elements in 3 arrays pythonfind the common words in two listsprint common elements in two lists pythoncommon values in two lists pythonfind common elements in 2 lists pythonpython keep common elements in two listsfind common items in two lists pythonpython count common elements in two listsnumber of elements which are not common in the two lists pythonget common values from multiple lists in pythonhow to check if there is a common element between two listsget common elements in different listsfind common items between two lists pythonget common elements in two lists pythoncommon elements in the two lists pythoncommon elements in two lists pythonget common elements from two lists