Answers for "list intersection java"

3

intersection in list

def intersection(lst1, lst2): 
    lst3 = [value for value in lst1 if value in lst2] 
    return lst3 
  
# Driver Code 
lst1 = [4, 9, 1, 17, 11, 26, 28, 54, 69] 
lst2 = [9, 9, 74, 21, 45, 11, 63, 28, 26] 
print(intersection(lst1, lst2))
Posted by: Guest on May-09-2020
0

get intersection of two lists java

Set<String> result = list.stream()  .distinct()  .filter(otherList::contains)  .collect(Collectors.toSet()); Set<String> commonElements = new HashSet(Arrays.asList("red", "green")); Assert.assertEquals(commonElements, result);
Posted by: Guest on July-30-2020

Python Answers by Framework

Browse Popular Code Answers by Language