Write the method
howMany which takes as parameters a
String[] headlines
containing the
headlines which you have cut out as well as a
String[] messages
with the messages you
may want to write, and returns an int which is the total number of
messages you can write.
headlines will contain between 1 and 50 elements, inclusive.
messages
will contain between 1 and 50 elements, inclusive.
headlines will be between 1 and 50 characters,
inclusive.
messages will be between 1
and 50 characters, inclusive.
headlines will only
contain the letters 'A'-'Z', 'a'-'z' and space.
messages will only contain the letters 'A'-'Z', 'a'-'z' and space.
headlines =
{"Earthquake in San Francisco",
"Burglary at musuem in Sweden",
"Poverty"}
messages =
{"Give me my money back",
"I am the best coder",
"TOPCODER"}
Returns: 2
In the first message we have three 'm's, but there are only two 'm's among the headlines (both in the word "museum"), so this message can't be written.
The second message can be written. Note that the first letter, 'I', only appears as lower case in the headlines, but that's allowed. The last message can also be written, so the method should return 2.
headlines =
{"Programming is fun"}
messages =
{"program","programmer","gaming","sing","NO FUN"}
Returns: 4
The messages "program", "gaming", "sing" and "NO FUN" can all be written but not "programmer" (no 'e's exist). The method should return 4.
headlines =
{"abcdef","abcdef"}
messages =
{"AaBbCc","aabbbcc"," ","FADE"}
Returns: 3
All messages except the second one can be written, because it contains three 'b's but there are only two 'b's available. Also note the message only containing spaces - such a message can of course always be written.