import java.util.*;
import java.util.stream.Collectors;
public class Hello{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
Set<Integer> numset=new TreeSet<>();;
while(sc.hasNextLine()){
List<Integer> numlist=Arrays.stream(sc.nextLine().trim().split("\\s+")).map(Integer::valueof).collect(Collectors.toList());
numSet.addAll(numList);
}
for(int num:numSet){
System.out.print(num+" ");
}
}
}
Solution:
numset=[]while True:try:numList=list(map(int,input().split()))numset.extend(numList)except:breakprint(*sorted((set(numset))))
0 Comments