Challenge: Find Duplicates in Array
Write a function to find the duplicates in an array in the most efficient way!
We'll cover the following
Problem Statement
Given an array, find all the duplicates that exist in that array.
Input
An array and its size
Output
A vector with the duplicates if they exist, and an empty vector if they don’t.
Sample Input
int arr[] = {1, 3, 4, 3, 5, 4, 100, 100};
int arrSize = 8;
Sample Output
vector<int> output = {3, 4, 100};
Coding Exercise
Take a close look and design a step-by-step algorithm before jumping on to implementation. This problem is designed for your practice, so try to solve it on your own first. If you get stuck, you can always refer to the hint and solution provided in the code tab. Good Luck!
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.