We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 731b1bb commit 6aba0d6Copy full SHA for 6aba0d6
src/main/java/com/packt/datastructuresandalg/lesson1/intersection/SimpleIntersection.java
@@ -1,12 +1,12 @@
1
package com.packt.datastructuresandalg.lesson1.intersection;
2
3
-import java.util.LinkedList;
+import java.util.ArrayList;
4
import java.util.List;
5
6
public class SimpleIntersection {
7
8
public List<Integer> intersection(int[] a, int[] b) {
9
- List<Integer> result = new LinkedList<>();
+ List<Integer> result = new ArrayList<>(a.length);
10
for (int x : a) {
11
for (int y : b) {
12
if (x == y) result.add(x);
0 commit comments