两个数组的交集
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Description
给定两个数组,编写一个函数来计算它们的交集。
示例 1:
输入: nums1 = [1,2,2,1], nums2 = [2,2] ,交集: [2]
示例 2:
输入: nums1 = [4,9,5], nums2 = [9,4,9,8,4] ,交集: [9,4]
说明,输出结果中的每个元素一定是唯一的,保证两数组均非空且交集一定存在。
Input Format
第一行两个整数n,m,分别为num1,num2的长度(1 ≤ n, m ≤ 100)
第二行n个整数,代表数组nums1
第三行m个整数,代表数组nums2
Output Format
按交集元素在num2中的顺序输出两数组的交集。
输出结果中的每个元素一定是唯一的。
4 2
1 2 2 1
2 2
2
Source
基础百练
2019蓝桥杯赛前训练Week3
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 6
- Start at
- 2019-1-28 13:00
- End at
- 2019-2-1 17:00
- Duration
- 100 hour(s)
- Host
- Partic.
- 11