Skip to content

Commit

Permalink
Create 0349-intersection-of-two-arrays.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
a93a authored Mar 10, 2024
1 parent 8d212e4 commit ab7ac03
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions kotlin/0349-intersection-of-two-arrays.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
fun intersection(nums1: IntArray, nums2: IntArray): IntArray {
val seen = nums1.toSet()

val res = mutableSetOf<Int> ()
for (n in nums2) {
if (n in seen)
res.add(n)
}

return res.toIntArray()
}
}

0 comments on commit ab7ac03

Please sign in to comment.