Skip to content

Commit 6aba0d6

Browse files
committed
changed linked list to array lise
1 parent 731b1bb commit 6aba0d6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/com/packt/datastructuresandalg/lesson1/intersection/SimpleIntersection.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.packt.datastructuresandalg.lesson1.intersection;
22

3-
import java.util.LinkedList;
3+
import java.util.ArrayList;
44
import java.util.List;
55

66
public class SimpleIntersection {
77

88
public List<Integer> intersection(int[] a, int[] b) {
9-
List<Integer> result = new LinkedList<>();
9+
List<Integer> result = new ArrayList<>(a.length);
1010
for (int x : a) {
1111
for (int y : b) {
1212
if (x == y) result.add(x);

0 commit comments

Comments
 (0)