Skip to content

Instantly share code, notes, and snippets.

@tjkhara
Created August 12, 2019 09:29
Show Gist options
  • Select an option

  • Save tjkhara/686525c5e0a80047e4a1671a0fd8d482 to your computer and use it in GitHub Desktop.

Select an option

Save tjkhara/686525c5e0a80047e4a1671a0fd8d482 to your computer and use it in GitHub Desktop.
Radix sort type method of finding duplicates
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