TopcoderArchiveVisit Topcoder
SRM12 Feb 2002
SRM 65

StrAnagram

Problem statement, definition, constraints, and public examples.

Problem Statement

PROBLEM STATEMENT
Given two String[]'s , a source list and a word list, you need to find how many
strings in the source list have an anagram in the word list.

Create a class StrAnagram that contains the method numAnagram, which takes two
String[], sourceList and wordList as input and returns the number of strings in
sourceList that have at least one anagram in wordList.

DEFINITION
Class Name: StrAnagram
Method Name: numAnagram
Parameters: String[] String[]
Return type: int
Method Signature( Make sure to make public ): int numAnagram(String[]
sourceList, String[] wordList)

NOTES
- Two Strings are anagrams of each other when one String is a
permutation(reordering the characters) of the other string.
- If two Strings are the same, they are to be considered anagrams of each other.
- All Strings comparisons are case sensitive. 

TopCoder will ensure the validity of the inputs.  Inputs are valid if all of
the following criteria are met:
- Both sourceList and wordList have 0 to 50 elements (inclusive).
- Each string in both the lists are 1 to 50 characters in length (inclusive). 
- All strings in the input contain only the letters('A'-'Z','a'-'z').

EXAMPLES
sourceList = {"ABCD","TopCoder","java"}
wordList = {"CDAB","rTedoopC","pink","DBAC"}
return value = 2

sourceList = {"apple","banana","orange","blueberry","dear"}
wordList = {"apple","blue","read","bblueerry","yrrebeulb"}
return value = 3

sourceList = {"dear","read"}
wordList = {"eard"}
return value = 2

sourceList = {"read"}
wordList = {"eard","dear"}
return value = 1

sourceList ={"abcd"}
wordList = {"DAbc"}
return value = 0

Definition

Class:
StrAnagram
Method:
numAnagram
Parameters:
String[], String[]
Returns:
int
Method signature:
int numAnagram(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