| Author |
How to print a String with out duplicates
|
Rahul Noel
Ranch Hand
Joined: Jul 18, 2008
Posts: 51
|
|
Hi, What I am asking is if String s="ABABAGTREE" and I what to this string with out duplicates that is output should be ABGTRE.How can I get it?
|
Thanks in Advance.
|
 |
Brij Garg
Ranch Hand
Joined: Apr 29, 2008
Posts: 234
|
|
|
You can use LinkedHashSet Collection class.
|
 |
Norm Radder
Ranch Hand
Joined: Aug 10, 2005
Posts: 681
|
|
|
Write a simple loop to get each char from the input string and save it in the output string if its not already saved.
|
 |
Brij Garg
Ranch Hand
Joined: Apr 29, 2008
Posts: 234
|
|
|
I think using collection classes is better as compared to writing loops. Loops are going to be very expensive in this case.
|
 |
Rahul Noel
Ranch Hand
Joined: Jul 18, 2008
Posts: 51
|
|
Sorry, I did get you guys could you explain with code.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
Originally posted by Jai Sriram: Sorry, I did get you guys could you explain with code.
No, please show us what code/pseudocode you would use. You learn a lot more if you show us what you have already achieved and we comment on it. And this is beginning to look like a beginner's question.
|
 |
 |
|
|
subject: How to print a String with out duplicates
|
|
|