Get Time

   Problem Statement  

 Problem Statement for LongLiveZhangzj

Problem Statement


Zhangzj is the emperor of Yali empire and is esteemed by his people.

"Long live Zhangzj" is heard across the country. Needless to say, people in the empire hope their leader will live forever. However, everybody will die, unless others donate their lives to the person.

In the empire, there's a special way to donate life. There are some fixed words that are called exciting. Whenever someone speaks an exciting word, he automatically donates one second of his life to Zhangzj. For example, "toad" and "river" are exciting. Then, if somebody says the sequence of words "a", "toad", "jumps", "into", "the", "toad", "river", they donate three seconds to Zhangzj.

Given a String[] speech containing all the words someone says, and a String[] words containing all exciting words, return the number of seconds the speaker will donate to Zhangzj.

A word may appear multiple times in speech, but not in words.



Parameters:String[], String[]
Method signature:int donate(String[] speech, String[] words)
(be sure your method is public)



Both speech and words will contain between 1 and 50 elements, inclusive.


All pairs of elements in words will be distinct.


Each element of speech and words will consist only of lowercase English letters.


The length of each element of speech and words will be between 1 and 50, inclusive.



{"make", "topcoder", "great", "again"}
{"make", "america", "great", "again"}
Returns: 3

"make", "great" and "again" appear in speech and are exciting. Thus, the answer is 3.

Returns: 0

The strings "toad" and "toads" are not identical, therefore this speaker does not donate any seconds to Zhangzj.

{"a", "a"}
Returns: 2

Two elements of speech can be the same.

{"je", "le", "ai", "deja", "vu", "et", "je", "le", "veux", "encore"}
{"i", "am", "having", "deja", "vu", "please", "stop", "the", "encore"}
Returns: 3

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.

This problem was used for:
       Single Round Match 719 Round 1 - Division II, Level One