Explore
ProGrad Programs
Placement Prep
TCS Codevita
Webinars
About Us

Edit
Reply




Edit

Program to find repeating element in an array (duplicate elements)

Published on 09 Mar 2020

An easier approach to find all repeating elements in an array is to use two loops. Use the first loop for traversing the array and the second loop to check if the current element is already encountered.


Algorithm


  1. Declare the array and input the array elements
  2. Start traversing the array and check if the current element is already encountered
  3. If it is already encountered, print the element as a repeating element and continue
  4. If not, move to the next element of the array and continue


C
C++

Output
Input- 1 2 3 1 2 Output- Repeating elements are 1 2


Recommended Programs





If you have any feedback about this article and want to improve this, please write to enquiry@faceprep.in