Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package DPM;
- import java.util.LinkedHashSet;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args){
- Scanner scan = new Scanner(System.in);
- int fNum = scan.nextInt();
- int sNum = scan.nextInt();
- LinkedHashSet<Integer> fSet = new LinkedHashSet<>();
- LinkedHashSet<Integer> sSet = new LinkedHashSet<>();
- for (int i = 0; i < fNum; i++) {
- int num = scan.nextInt();
- fSet.add(num);
- }
- for (int i = 0; i < sNum; i++) {
- int num = scan.nextInt();
- sSet.add(num);
- }
- fSet.retainAll(sSet);
- for (Integer integer : fSet) {
- System.out.print(integer+ " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement