• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

How to remove repeated letters from String

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Here is my String

String s = "51681561";

Now i want to remove the repeated numbers from the above String.(I want to print the Unique number from the above String)

Thanks,
Praneeth.
 
lowercase baba
Posts: 12935
65
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what have you tried doing? How would you do it by hand, if you didn't have a computer?

The first step in writing a program is always to work out the algorithm by hand. Have you done that?

 
Ranch Hand
Posts: 300
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is this an interview questions or homework exercise ?

by the way you can solve this problem by two ways

1) iterative
loop through start to end and store char and count in hashmap display all char which has 1 count.

2) recursive
left as exercise
 
fred rosenberger
lowercase baba
Posts: 12935
65
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for the ten digits, you don't even need a hashmap...and int array would suffice
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic