Intersection of Lists

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 1.0s
Memory limit: 32M

Author:
Problem type
Allowed languages
Python

Given two integer arrays nums1 and nums2, output a list of their intersection. Each element in the result must be unique and listed in ascending order. Note that if their intersection is an empty set, the resulting list should be an empty list [].

Input Specification

The first line of the input gives the number of test cases, T, and then T test cases follow.

For each test case, it will consist of two lines, where the first line contains n integers separated by spaces, and the second line contains m integers separated by spaces.

Constraints

1 \leq T \leq 100

1 \leq n \leq 100

1 \leq m \leq 100

0 \leq nums1[i] \leq 199

0 \leq nums2[i] \leq 199

Output Specification

For each test case, output one line containing Case #x: y, where x is the case number(starting from 1), and y is the intersection list of the given input lists. Note that the elements in the intersection list should be in ascending order.

Sample Input

2
1 2 2 1
2 2
4 9 5
9 4 9 8 4

Sample Output

Case #1: [2]
Case #2: [4, 9]

Hint

set sort

Reference

https://leetcode.com/problems/intersection-of-two-arrays/


Comments

There are no comments at the moment.