TopCoder problem "DietPlan" used in SRM 372 (Division II Level One)



Problem Statement

    

The doctor has given you your diet, in which each character corresponds to some food that you should eat. You also know what you have eaten for breakfast and lunch, in which each character corresponds to a type of food that you have already eaten that day. You have decided that you will eat all of the remaining food in your diet during dinner, and you want to return that as a String (sorted in alphabetical order). If you have cheated in anyway (either by eating too much of one type of food, or by eating some food that is not in the dietPlan), you should return the String "CHEATER" (quotes for clarity).

 

Definition

    
Class:DietPlan
Method:chooseDinner
Parameters:String, String, String
Returns:String
Method signature:String chooseDinner(String diet, String breakfast, String lunch)
(be sure your method is public)
    
 

Constraints

-diet will contain between 0 and 26 characters, inclusive.
-Each character in diet will be an uppercase letter ('A'-'Z').
-There will be no duplicate characters in diet.
-breakfast will contain between 0 and 26 characters, inclusive.
-Each character in breakfast will be an uppercase letter ('A'-'Z').
-lunch will contain between 0 and 26 characters, inclusive.
-Each character in lunch will be an uppercase letter ('A'-'Z').
-There will be no duplicate characters in breakfast.
-There will be no duplicate characters in lunch.
-No character will appear in both breakfast and lunch.
 

Examples

0)
    
"ABCD"
"AB"
"C"
Returns: "D"
Here, you have eaten most of your food for the day. So, you can only eat a single 'D' for dinner.
1)
    
"ABEDCS"
""
""
Returns: "ABCDES"
Here you've saved all of your food for dinner.
2)
    
"EDSMB"
"MSD"
"A"
Returns: "CHEATER"
You cheated at lunch time by eating an 'A'!
3)
    
""
""
""
Returns: ""
4)
    
"IWANTSODER"
"SOW"
"RAT"
Returns: "DEIN"

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=8222

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10789&pm=8222

Writer:

connect4

Testers:

PabloGilberto , radeye , Olexiy , Andrew_Lazarev

Problem categories:

String Parsing