Created
August 12, 2019 09:29
-
-
Save tjkhara/686525c5e0a80047e4a1671a0fd8d482 to your computer and use it in GitHub Desktop.
Radix sort type method of finding duplicates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FindDuplicates2 { | |
| public static void main(String args[]) { | |
| int intArray[] = { 1, 2, 3, 4, 1 }; | |
| findDuplicates(intArray); | |
| } | |
| public static void findDuplicates(int[] id) { | |
| System.out.println("Duplicate data: "); | |
| int count[] = new int[10]; | |
| for (int i = 0; i < id.length; i++) { | |
| count[id[i]]++; | |
| if (count[id[i]] == 2) { | |
| System.out.println(id[i] + " "); | |
| } | |
| } | |
| System.out.println(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment