Help me in solving DR problem

My issue

My code

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner s=new Scanner (System.in);
		int t=s.nextInt();
		for(int j=0;j<t;j++){
		    int n=s.nextInt();
		    LinkedList<Integer> a=new LinkedList<>();
		    for(int i=0;i<n;i++){
		        a.add(s.nextInt());
		    }
		    HashSet<Integer> h=new HashSet<>(a);
		    LinkedList<Integer> r=new LinkedList<>();
		    for(Integer k:h){
		        if(Collections.frequency(a,k)==1){
		            r.add(k);
		            
		    }
		     
		    
		}for(int i=0;i<r.size();i++){
		
		System.out.print(r.get(i)+" ");}
		System.out.println();
	}
}
}

Learning course: Placement preparation using Java
Problem Link: CodeChef: Practical coding for everyone