Last active
September 1, 2019 08:07
-
-
Save setanjan123/000256c3c094ce469e14c2b21b421e02 to your computer and use it in GitHub Desktop.
This file contains 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 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