SHOPLINE Limited interview question

Code test with deduplicate smallest array