Drupal 8 - How to add custom class to a drupal table view
Introduction Suppose you have a view, and you have configured your display as a…
July 04, 2019
Suppose you have two lists, and you want Union and Intersection of those two lists.
Input:
list1: [1, 2, 3, 4]
list2: [3, 4, 5, 6]
union(list1, list2): [1, 2, 3, 4, 5, 6]
intersection(list1, list2): [3, 4]
See the java code for multiple solutions:
public static List<Integer> getIntersection_1(List<Integer> l1, List<Integer> l2) {
return l1.stream().filter(l2::contains).collect(Collectors.toList());
}
public static List<Integer> getIntersection_2(List<Integer> l1, List<Integer> l2) {
Set<Integer> s1 = new HashSet<>(l1);
s1.retainAll(l2);
return new ArrayList<>(s1);
}
public static List<Integer> getIntersection_3(List<Integer> l1, List<Integer> l2) {
List<Integer> list = new ArrayList<Integer>();
for (Integer i : l1) {
if(l2.contains(i)) {
list.add(i);
}
}
return list;
}
public static List<Integer> getUnion_1(List<Integer> l1, List<Integer> l2) {
Set<Integer> result = new HashSet<Integer>();
result.addAll(l1);
result.addAll(l2);
return new ArrayList<Integer>(result);
}
public static List<Integer> getUnion_2(List<Integer> l1, List<Integer> l2) {
Set<Integer> s1 = new HashSet<>(l1);
s1.addAll(l2);
return new ArrayList<>(s1);
}
Introduction Suppose you have a view, and you have configured your display as a…
Introduction In this post, we will see: use Grafana Community Edition (Free…
Problem Statement I have a drupal module, where there is a file of extension…
Thanks for reading.
MongoDB CRUD Operations Mongoose provides a simple schema based solution to…
Introduction I have a host running mysql (not on a container). I have to run an…
In this post, we will see some of the frequently used concepts/vocabulary in…
System design interview is pretty common these days, specially if you are having…
Introduction You are given an array of integers with size N, and a number K…
Graph Topological Sorting This is a well known problem in graph world…
Problem Statement Given a Binary tree, print out nodes in level order traversal…
Problem Statement Given an array nums of n integers and an integer target, are…