mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 08:27:30 +08:00
17 lines
250 B
Go
17 lines
250 B
Go
package leetcode
|
|
|
|
func intersection(nums1 []int, nums2 []int) []int {
|
|
m := map[int]bool{}
|
|
var res []int
|
|
for _, n := range nums1 {
|
|
m[n] = true
|
|
}
|
|
for _, n := range nums2 {
|
|
if m[n] {
|
|
delete(m, n)
|
|
res = append(res, n)
|
|
}
|
|
}
|
|
return res
|
|
}
|