Write code for printing duplicate numbers in a list.

AnswerBot
1y

Code to print duplicate numbers in a list.

  • Iterate through the list and keep track of the count of each number using a dictionary.

  • Print the numbers that have a count greater than 1.

Praveen S Kotagunasi
2mo
Given a list of integers with duplicate elements in it. The task is to generate another list, which contains only the duplicate elements. In simple words, the new list should contain elements that app...read more
Chavhan Vijay
1y
  1. A= [1, 2, 3, 4, 2, 7, 8, 8, 3];

  2. print("Duplicate elements are: ");

  3. #Searches for duplicate element

  4. for i in range(0, len(A)):

  5. for j in range(i+1, len(A)):

  6. if(A[i] == A[j]):

  7. print(A[j]);

Comment deleted
Add answer anonymously...
EPAM Systems Data Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter