Skip to content

Files

Latest commit

 

History

History
48 lines (30 loc) · 1.13 KB

349-intersection-of-two-arrays.md

File metadata and controls

48 lines (30 loc) · 1.13 KB

349. Intersection of Two Arrays - 两个数组的交集

给定两个数组,编写一个函数来计算它们的交集。

示例 1:

输入: nums1 = [1,2,2,1], nums2 = [2,2]
输出: [2]

示例 2:

输入: nums1 = [4,9,5], nums2 = [9,4,9,8,4]
输出: [9,4]

说明:

  • 输出结果中的每个元素一定是唯一的。
  • 我们可以不考虑输出结果的顺序。

题目标签:Sort / Hash Table / Two Pointers / Binary Search

题目链接:LeetCode / LeetCode中国

题解

Language Runtime Memory
ruby 84 ms N/A
# @param {Integer[]} nums1
# @param {Integer[]} nums2
# @return {Integer[]}
def intersection(nums1, nums2)
    nums1 & nums2
end