Intersection of Sets with Duplicates
Python
Medium
sets
Task «Intersection of Sets with Duplicates»
Two strings containing integers separated by spaces are given. It is necessary to find all numbers that appear in both strings and output them in ascending order without repetitions. If there are no such numbers, output 'NO'. Use sets to solve the problem.
Input Format
Two strings, each containing integers separated by spaces. The number of integers in each string ranges from 1 to 1000, and the absolute value of the numbers does not exceed 10^9.
Output Format
One line: numbers that are present in both strings, in ascending order, separated by spaces. If there are no such numbers, output 'NO'.
Examples
Example 1
INPUT
10 20 30
40 50 60
OUTPUT
NO
Example 2
INPUT
7 7 7 7
7 7 7
OUTPUT
7
main.py