#C11668. Find Duplicates in an Array
Find Duplicates in an Array
Find Duplicates in an Array
Problem Description:
Given an array of integers, your task is to identify all the numbers that occur more than once. You should output the duplicate numbers in sorted order. If no duplicates are found, output the string No duplicates
.
To solve this problem, count the frequency of each integer and then select those with a count greater than one. The expected time complexity is (O(n \log n)) in the worst-case scenario due to the sorting step.
inputFormat
The first line of input contains an integer (n), representing the number of elements in the array. The second line contains (n) space-separated integers.
outputFormat
If duplicates exist, output the sorted duplicate numbers separated by a single space. Otherwise, output the string "No duplicates".## sample
6
4 2 3 4 1 2
2 4