• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to print a String with out duplicates

 
Rahul Noel
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Brij Garg
Ranch Hand
Posts: 234
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use LinkedHashSet Collection class.
 
Norm Radder
Ranch Hand
Posts: 707
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 234
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I did get you guys could you explain with code.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic