Skip to content

Commit ab7ac03

Browse files
authored
Create 0349-intersection-of-two-arrays.kt
1 parent 8d212e4 commit ab7ac03

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
fun intersection(nums1: IntArray, nums2: IntArray): IntArray {
3+
val seen = nums1.toSet()
4+
5+
val res = mutableSetOf<Int> ()
6+
for (n in nums2) {
7+
if (n in seen)
8+
res.add(n)
9+
}
10+
11+
return res.toIntArray()
12+
}
13+
}

0 commit comments

Comments
 (0)