Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package ktgk;
- import java.util.*;
- /**
- *
- * @author nguyenanhkiet
- * Tach va tim tu
- */
- public class KTGK {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Scanner cin = new Scanner(System.in);
- int t = Integer.parseInt(cin.nextLine());
- while(t-->0){
- String s1 = cin.nextLine();
- String s2 = cin.nextLine();
- ArrayList<String> check = new ArrayList<>();
- String s1t[] = s1.trim().split("\\s+");
- for(String i : s1t){
- check.add(i.toLowerCase());
- }
- String s2t[] = s2.trim().split("\\s+");
- for(String i : s2t){
- String temp = i.toLowerCase();
- int before = Collections.frequency(check, temp);
- check.add(temp);
- int after = Collections.frequency(check, temp);
- if(after - before == 1 && before != 0){
- System.out.print(i + " ");
- }
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement