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 or more parties within 5 days of each other.
Given a
Definition
- Class:
- Probation
- Method:
- punish
- Parameters:
- String[]
- Returns:
- String[]
- Method signature:
- String[] punish(String[] schedule)
- (be sure your method is public)
Notes
- 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", "SAE","LSJUMB","AEP","AEP","LSJUMB"}
Returns: { "SAE" }
LSJUMB throws parties on days 0, 4, 6, and 9. Since no 3 of these days are within 5 days of each other, they are not eligible for alcohol probation. SAE throws parties on days 1, 3, and 5, which are within 5 days of each other, so they become eligible for alcohol probation. AEP throws parties on days 2, 7, and 8, so they are also not eligible for alcohol probation.
{"LSJUMB","SAE","SAE","LSJUMB", "LSJUMB","SAE","AEP","AEP","AEP"}
Returns: { "LSJUMB", "SAE", "AEP" }
All 3 groups throw 3 parties within 5 days of their other 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", "D" }
{"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", "KA" }
{"A","B","C","C","A","B","C","A", "B","B","C","A","A","B","C","A"}
Returns: { "C", "B", "A" }
{"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: { "J", "C" }
{"I","F","H","F","A","H","E","H","J","G","C"}
Returns: { }
{"H","H","I","A","I","A","J","G","C","E", "J","G","H","H","E","H","I","I","D","G", "H","B","D","F","J","I","H","D","H","C", "D","J","C","F","G","D","D","B","F"}
Returns: { "H" }
{"C","G","F","B","H","D","C","F","J", "B","H","A","I","B","I","I","I","I", "J","J","B","I","D","C","J","C","G", "G","B","B","B","C","J","J","H","F","H"}
Returns: { "I", "B" }
{"D","H","G","H","J","J","G","F", "B","I","G","I","C","I","F","G", "B","A","I","B","C","A","D","B", "H","J","A","D","A","H","B","F", "B","D","G","D","C","D","C"}
Returns: { "I", "D" }
{"I","I","A","I","D","H","A","E", "C","C","C","G","A","A","I","G", "A","G","H","B","F","I","F","E", "B","I","D","B","C","B","H","A", "D","A","E","D","J","E","D","A", "C","A","C","A","C","J","B","F","F"}
Returns: { "I", "C", "A" }
{"H","D","H","J","D","C","C","B", "H","C","A","H","E","E","H","J", "H","E","I","H","H","J","J","E","J"}
Returns: { "C", "H", "J" }
{"J","I","D","J","E","A","C","E","G", "E","A","J","A","J","C","E","B","F", "B","B","D","G","D","E","G","I","A", "A","I","A","E","C","H","C","C","F","G"}
Returns: { "B", "A", "C" }
{"A","D","E","I","A","E","F","D", "D","H","D","H","E","H","I","C", "D","C","A","B","B","G","B","A", "E","D","B","E","E","H","F","J", "G","I","F","J","E","F","I","G","J","C"}
Returns: { "D", "H", "B", "E" }
{"D","B","I","I","I","F","A","E","G","A", "A","D","E","D","D","J","G","H","H","J", "B","J","J","B","C","H","H","F","B","J", "B","C","B","D","F","F","A","F","E","F", "H","H","D","D","I","H","B"}
Returns: { "I", "A", "D", "J", "B", "F" }
{"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", "H", "E", "C", "F" }
{}
Returns: { }
{ "A", "A", "A" }
Returns: { "A" }
{ "A", "B", "B", "C", "C", "D", "C", "D", "A", "A", "A" }
Returns: { "C", "A" }
{ "B", "B", "B" }
Returns: { "B" }
{ "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A" }
Returns: { "A" }
{ "A", "A", "B", "B", "B", "A", "A", "A" }
Returns: { "B", "A" }
{ "A", "B", "C", "B", "A", "B", "C", "B", "A", "B", "D", "D" }
Returns: { "B" }
{ "A", "A", "A", "B" }
Returns: { "A" }