PROBLEM STATEMENT:
Sometimes one word appears within another word, but the characters that make
up the word are somehow dispersed or scrambled within the second word. A word
can either appear completely within another word, or appear only partially.
You can emphasize the complete or partial occurrence of one word within another
by capitalizing the characters that the two words share.
Write a method which accomplishes this keeping the following in mind:
* In this problem, a character's uniqueness is determined by the letter it
represents and by the amount of times that letter has previously appeared
within its word. So for example the word "asa" contains the following
characters: 0-th a, 0-th s, and 1-st a. While the word "assassin" contains
the following: 0-th a, 0-th s, 1-st s, 1-st a, 2-nd s, 3-rd s, 0-th i, and 0-th
n. So, the strings "asa" and "assassin" have only three characters in common,
the 0-th a, the 0-th s, and 1-st a. Emphasizing "asa" within "assassin" makes
"ASsAssin".
DEFINITION:
class name: WordChange
method name: capitalize
parameters: String, String
return type: String
method signature: (make sure your method is public) String capitalize(String
word, String changer)
TopCoder will ensure the validity of these inputs:
-- word is a String of length 0 to 50 inclusive comprised of lowercase letters
'a'-'z'
-- changer is a String of length 0 to 50 inclusive comprised of lowercase
letters 'a'-'z'
FURTHER EXAMPLES:
olfactory, far zz, zzz olfactory, "" "", empty
return: olFActoRy return: ZZ return olfactory
return ""
concatanate, cognac dogma dog dogma, amgod idiom, middle
return: CONCAtanate return DOGma return DOGMA return IDioM