Skip to content

Instantly share code, notes, and snippets.

@orhanobut
Last active December 23, 2015 12:49
Show Gist options
  • Save orhanobut/6637877 to your computer and use it in GitHub Desktop.
Save orhanobut/6637877 to your computer and use it in GitHub Desktop.
Remove duplicates with using an extra buffer. Complexity = O (n)
public static void removeDuplicates(int[] a){
Set<Integer> s = new HashSet<Integer>();
for (int i : a) {
s.add(i);
}
s.toArray();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment