Return Duplicate Numbers

Published by Matt in

Given an array nums where each integer is between 1 and 100, return a sorted array containing only duplicate numbers from the given nums array.

Examples

duplicate_nums([1, 2, 3, 4, 3, 5, 6]) ➞ [3]

duplicate_nums([81, 72, 43, 72, 81, 99, 99, 100, 12, 54]) ➞ [72, 81, 99]

duplicate_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) ➞ nil

Notes

The given array won't contain the same number three times.

Watch a quick demo on how Edabit works.