• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to find whether strings contained in array of strings constitute a similar character or not?  RSS feed

 
Utsav Harsh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having an array of strings and i want to find out whether these strings contained in the array contain a similar character or not.
For example i am having following strings in the array of string:

aadafbd
dsfgdfbvc
sdfgyub
fhjgbjhjd

my program should provide following result:
3
because i have 3 characters which are similar in all the strings of the array(f,b,d).
Can anyone provide me any kind of help?

 
Knute Snortum
Sheriff
Posts: 4270
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start with writing out what you want the program to do, step by step, then try changing the steps into code. Post the code and any specific problems you have.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12562
49
Chrome Java Linux
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Utsav Harsh wrote:For example i am having following strings in the array of string:

aadafbd
dsfgdfbvc
sdfgyub
fhjgbjhjd

my program should provide following result:
3
because i have 3 characters which are similar in all the strings of the array(f,b,d).

An example is great for illustrative purposes, but it isn't a spec.

Your spec should spell out what to do in all cases and be completely unambiguous. It should include and and all end- and corner-cases you can think of. Is the number of strings always going to be four? Can you have an empty string? etc.

Part of the reason I'm pushing you to write a better spec is that it will make you think about the problem in more detail, and thus make writing the actual code easier.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!