Skip to content

Instantly share code, notes, and snippets.

@setanjan123
Last active September 1, 2019 08:07
Show Gist options
  • Save setanjan123/000256c3c094ce469e14c2b21b421e02 to your computer and use it in GitHub Desktop.
Save setanjan123/000256c3c094ce469e14c2b21b421e02 to your computer and use it in GitHub Desktop.
public String eliminateDuplicates(String in)
{
HashSet<String> set=new HashSet<String>();
String out="";
for(int i=0;i<in.length();i++)
{
String ch=in.substring(i,i+1);
if(!set.contains(ch))
{
out=out+ch;
set.add(ch);
}
}
return out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment