Statistics

Problem Statement for "Alcohol"

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 String[], schedule, which represents which group throws a party on each day, return a String of the first group that becomes legally eligible for alcohol probation. Each element of schedule will represent one day. If the same group throws 3 or more parties, it becomes legally eligible for alcohol probation.

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

  1. {"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.

  2. {"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".

  3. {"A","B","C","B","A","B","C","B","A","B","D","D","D"}

    Returns: "B"

  4. {"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"

  5. {"A","B","C","C","A","B","C","A","B","B","C","A","A","B","C","A"}

    Returns: "C"

  6. {"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"

  7. {"I","F","H","F","A","H","E","H","J","G","C"}

    Returns: "H"

  8. {"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"

  9. {"O","I","Q","T","J","R","H","A","Z","Z","L","Q","N","C","Z","K","T","D","V","D","C","G"}

    Returns: "Z"

  10. {"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"

  11. {"B","S","W","J","Y","B","H","E","A","V","U","H"}

    Returns: ""

  12. {"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"

  13. {"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"

  14. {"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"

  15. {"F","K","D","F"}

    Returns: ""

  16. {"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"

  17. {}

    Returns: ""

  18. { "Z", "Z", "Z", "A", "A", "A" }

    Returns: "Z"

  19. { "A", "A", "A", "B", "B", "B", "B", "B", "D", "D", "D", "D", "D", "D", "D", "D", "F", "F", "F", "F", "F", "F" }

    Returns: "A"

  20. { "DOG", "CAT", "MOUSE", "CAT", "CAT" }

    Returns: "CAT"

  21. { "A", "A", "B", "C", "D" }

    Returns: ""

  22. { "B", "S", "W", "J", "Y", "B", "H", "E", "A", "V", "U", "H" }

    Returns: ""

  23. { "ABC", "FFF", "FFF", "FF", "FFF", "ABC", "ABC", "ABC", "ABC" }

    Returns: "FFF"

  24. { "A", "B", "A", "C", "C", "D", "A" }

    Returns: "A"

  25. { "A", "B", "B", "B", "A", "A", "A", "A" }

    Returns: "B"

  26. { "A", "B", "B", "C", "C", "B", "C", "C", "C", "D", "D", "D", "D", "D", "D", "D", "D" }

    Returns: "B"

  27. { "A", "B", "B", "B", "A", "A", "A", "A", "A", "A", "A" }

    Returns: "B"

  28. { "A", "B", "C", "C", "C" }

    Returns: "C"

  29. { "A", "O", "O", "O", "A", "A" }

    Returns: "O"

  30. { "A", "A", "A" }

    Returns: "A"

  31. { "ABC", "ABC", "DEF", "DEF", "GHI", "GHI", "GHI", "XYZ" }

    Returns: "GHI"


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)2024, TopCoder, Inc. All rights reserved.
This problem was used for: