TopcoderArchiveVisit Topcoder
SRM23 May 2001
SRM 3

CommonChar

Problem statement, definition, constraints, and public examples.

Problem Statement

Class Name: CommonChar
Method Name: compare
parameters:  String, String
returns: int

Create a class CommonChar containing the method compare. This method will take
two Strings as inputs and return the number of characters in the second String
that are contained in the first string, in a one-to-one relationship.  That is,
if a character is repeated in the second string, it must be repeated in the
first string to count more than once.

Here is the method signature:
public int compare(String input1, String input2);

BOth Strings will have fewer than 100 characters.

Note:
-The method is case sensitive.  A is a different character than a.

Examples:
("java", "abava") -> 3  (two of the (a)s and the (v))
("TopCoder", "code guru") -> 4
("foobar", "sing") -> 0 

Definition

Class:
CommonChar
Method:
compare
Parameters:
String, String
Returns:
int
Method signature:
int compare(String param0, String param1)
(be sure your method is public)

Constraints

    Examples

      No public sample cases were explicitly marked for this problem in the original data.

      Back to all problems