package set.example.pkg1; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; class GfG { /*inserts an element x to the set s */ void insert(Set s, int x) { // Your code here s.add(x); } /*prints the contents of the set s in ascending order */ void print_contents(Set s) { // Your code here List list = new ArrayList(s); Collections.sort(list); for(Integer i : list){ System.out.print(i + " "); } } /*erases an element x from the set s */ void erase(Set s, int x) { // Your code here s.remove(x); } /*returns the size of the set s */ int size(Set s) { // Your code here return s.size(); } /*returns 1 if the element x is present in set s else returns -1 */ int find(Set s, int x) { // Your code here if(s.contains(x)) { return 1; } else { return -1; } } } public class SetExample1 { public static void main(String[] args) { // TODO code application logic here Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t>0) { Set s = new HashSet() ; int q = sc.nextInt(); while(q>0) { GfG g = new GfG(); char c = sc.next().charAt(0); if(c == 'a') { int x = sc.nextInt(); g.insert(s,x); } if(c =='b') { g.print_contents(s); } if(c == 'c') { int x = sc.nextInt(); g.erase(s,x); } if(c == 'd') { int x = sc.nextInt(); System.out.print(g.find(s,x)+" "); } if(c == 'e') System.out.print(g.size(s)+" "); q--; //System.out.println(); } t--; System.out.println(); } } }