Problem Statement
The Stanford Office of Student Affairs has been placing student groups (including the one, the only, the truly incomparable, Leland Stanford Junior University Marching Band) on alcohol probation. However, due to some legal nitpicking, they are only allowed to place a group on alcohol probation if it throws 3 parties in a given year.
Given a
If no group becomes legally eligible for alcohol probation, return "".
Definition
- Class:
- Alcohol
- Method:
- punish
- Parameters:
- String[]
- Returns:
- String
- Method signature:
- String punish(String[] schedule)
- (be sure your method is public)
Notes
- If no group becomes legally eligible for alcohol probation, return "".
- Element 0 of schedule represents day 0, element 1 represents day 1, and so on. Thus, each day, there is exactly one group that throws a party.
Constraints
- schedule will contain between 0 and 50 elements, inclusive.
- each element of schedule will contain 1 to 10 characters, inclusive.
- each element of schedule will only contain capital letters [A-Z].
Examples
{"LSJUMB","SAE","AEP","SAE","LSJUMB","LSJUMB","AEP","LSJUMB"}
Returns: "LSJUMB"
LSJUMB throws 4 parties, while SAE and AEP throw only 2. Therefore LSJUMB is the only group that is legally eligible for alcohol probation.
{"LSJUMB","SAE","SAE","LSJUMB","LSJUMB","SAE","AEP","AEP","AEP"}
Returns: "LSJUMB"
All 3 groups throw 3 parties, so they are all eligible for alcohol probation. The order in which they become eligible is "LSJUMB", "SAE", "AEP".
{"A","B","C","B","A","B","C","B","A","B","D","D","D"}
Returns: "B"
{"KA","SX","TAXI","TAXI","SX","SX","KA","TAXI","KA","KA","TAXI","KA", "TAXI","ST","KA","KA","KA","KA","KA","SX","SX","SX","SX","SX"}
Returns: "SX"
{"A","B","C","C","A","B","C","A","B","B","C","A","A","B","C","A"}
Returns: "C"
{"D","A","E","C","E","A","B","J","C","A","G","J","J","I","D","J","B", "J","F","E","C","D","C","C","J","D","H","E","D","I","F","F","C","D"}
Returns: "A"
{"I","F","H","F","A","H","E","H","J","G","C"}
Returns: "H"
{"B","C","B","B","H","H","J","H","C","G","D","C","H","F","A", "E","J","E","C","E","H","A","H","A","F","J","B","J","E","I", "A","B","C","J","C","C","J","E","F","B","A","F","F","E","C"}
Returns: "B"
{"O","I","Q","T","J","R","H","A","Z","Z","L","Q","N","C","Z","K","T","D","V","D","C","G"}
Returns: "Z"
{"W","L","T","T","G","X","B","S","U","G","L","B","Y","V","T","O","R","B","J","G","P","Y","U","T","H"}
Returns: "T"
{"B","S","W","J","Y","B","H","E","A","V","U","H"}
Returns: ""
{"F","J","O","K","N","H","I","F","O","B","O","F","E","G","N","L","D","C","D","C","H","I","J","A","O","J","M","J","D"}
Returns: "O"
{"A","I","B","K","I","D","N","D","M","C","D","H","B","L","K","B","E","M","B","C","J","I","C","J","N","G","B","F","C","L","K","K","J","F","O","C","A","I","C","D"}
Returns: "D"
{"F","D","F","I","C","G","L","M","B","A","H","I","F","G","K","O","A","K","F","O","H","G","D","H","A","A","B","B","L","M","N","C","O","O","B"}
Returns: "F"
{"F","K","D","F"}
Returns: ""
{"K","K","L","F","K","F","N","M","I","O","B","J","L","K","K","E","J","I","D","O","F","M","H","D","E"}
Returns: "K"
{}
Returns: ""
{ "Z", "Z", "Z", "A", "A", "A" }
Returns: "Z"
{ "A", "A", "A", "B", "B", "B", "B", "B", "D", "D", "D", "D", "D", "D", "D", "D", "F", "F", "F", "F", "F", "F" }
Returns: "A"
{ "DOG", "CAT", "MOUSE", "CAT", "CAT" }
Returns: "CAT"
{ "A", "A", "B", "C", "D" }
Returns: ""
{ "B", "S", "W", "J", "Y", "B", "H", "E", "A", "V", "U", "H" }
Returns: ""
{ "ABC", "FFF", "FFF", "FF", "FFF", "ABC", "ABC", "ABC", "ABC" }
Returns: "FFF"
{ "A", "B", "A", "C", "C", "D", "A" }
Returns: "A"
{ "A", "B", "B", "B", "A", "A", "A", "A" }
Returns: "B"
{ "A", "B", "B", "C", "C", "B", "C", "C", "C", "D", "D", "D", "D", "D", "D", "D", "D" }
Returns: "B"
{ "A", "B", "B", "B", "A", "A", "A", "A", "A", "A", "A" }
Returns: "B"
{ "A", "B", "C", "C", "C" }
Returns: "C"
{ "A", "O", "O", "O", "A", "A" }
Returns: "O"
{ "A", "A", "A" }
Returns: "A"
{ "ABC", "ABC", "DEF", "DEF", "GHI", "GHI", "GHI", "XYZ" }
Returns: "GHI"