β Repeating numbers
Repeating numbers medium asked in interviews by 1 company Time Limit: 2 sec Memory Limit: 128000 kB
```java
import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework
// don't change the name of this class
// you can add inner classes if needed
class Main {
public static void main (String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
TreeSet<Integer>hs=new TreeSet<>();
TreeSet<Integer>h=new TreeSet<>();
for(int i=0;i<n;i++){
hs.add(sc.nextInt());
}
for(int i=0;i<m;i++){
int a=sc.nextInt();
if(hs.contains(a)){
h.add(a);
}
}
for(Integer hm:h){
System.out.print(hm+" ");
}
}
}
```Last updated