About 5,090,000 results
Open links in new tab
  1. Find duplicate elements in an array - GeeksforGeeks

    Dec 19, 2024 · Given an integer array arr[], print all distinct elements from this array. The given array may contain duplicates and the output should contain every element only once. Examples: Input: arr[] = {12, 10, 9, 45, 2, 10, 10, 45}Output: {12, 10, 9, 45, 2} Input: arr[] = {1, 2, 3, 4, 5}Output: {1, 2, 3, 4

  2. Java: Find the duplicate values of an array of integer values

    May 9, 2025 · Java exercises and solution: Write a Java program to find duplicate values in an array of integer values.

  3. Check if array contains duplicates - GeeksforGeeks

    Aug 29, 2024 · Given an integer array arr[], check if the array contains any duplicate value. Examples: Input: arr[] = {4, 5, 6, 4} Output: true Explanation: 4 is the duplicate value. Input: arr[] = {1, 2, 3, 4} Output: false Explanation: All values are distinct.

  4. Java Array, Finding Duplicates - Stack Overflow

    Oct 17, 2010 · public static ArrayList<Integer> duplicate(final int[] zipcodelist) { HashSet<Integer> hs = new HashSet<>(); ArrayList<Integer> al = new ArrayList<>(); for(int element: zipcodelist) { if(hs.add(element)==false) { al.add(element); } } return al; }

  5. Java program to find the duplicate values of an array of integer

    Mar 16, 2018 · What you can do, is use a data structure that only contains unique values, Set. In this case we use a HashSet to store all the duplicates. Then you check if the Set contains your value at index i, if it does not then we loop through the array to try and find a duplicate.

  6. Java Program to Find Duplicate Elements in an Array - Java Guides

    Use a Nested Loop to Find Duplicates: Compare each element with every other element in the array to find duplicates. Display the Duplicate Elements: Print the duplicate elements found in the array. Approach 1: Using Nested Loops

  7. Program to Print the Duplicate Elements of an Array - Java

    The HashSet method is one of the most efficient ways to find duplicates in an array. A HashSet allows unique elements. So, whilst we attempt to add a detail that already exists within the set, we will realise that the factors are duplicates.

  8. Find Duplicate Elements and Their Frequency in an Array in Java

    Jan 5, 2023 · Learn how to find duplicate elements and their frequency in an array using Java. This guide provides step-by-step instructions and code examples.

  9. 3 Ways to Find Duplicate Elements in an Array - Java - Blogger

    Apr 13, 2023 · There are multiple ways to find duplicate elements in an array in Java and we will see three of them in this program. The solution and logic shown in this article are generic and apply to an array of any type e.g. String array or integer array or array of any object.

  10. Java Program to Find duplicates in an Array – Learn Programming

    Jul 5, 2024 · This program demonstrates how to find duplicate elements in an array using Java. The algorithm iterates through the array and uses a HashSet to track seen elements. If an element is found in the HashSet , it is identified as a duplicate.

  11. Some results have been removed
Refresh