Statistics

Problem Statement for "Birthday"

Problem Statement

Forgetting a close friend's birthday is quite embarrassing, but forgetting it two years in a row is a catastrophe. So what can a coder do to prevent this from happening again? Well, the thing he possibly can do best: code...

Given a String date (the current date) and a String[] birthdays, a list of people's birthdays and names, return a String, the date of the next occurring birthday, starting from the current date.

date is in the format "MM/DD" (quotes for clarity), where MM represents the two-digit month and DD represents the two-digit day (leading zero if necessary). Each element of birthdays is in the format "MM/DD <Name>" (quotes for clarity), where MM/DD is the date of <Name>'s birthday. <Name> is a sequence of characters from 'A'-'Z' and 'a'-'z'. There is exactly one space character between the date and <Name>. The date returned also has to be in the format "MM/DD" (quotes for clarity).

Definition

Class:
Birthday
Method:
getNext
Parameters:
String, String[]
Returns:
String
Method signature:
String getNext(String date, String[] birthdays)
(be sure your method is public)

Constraints

  • birthdays contains between 1 and 50 elements, inclusive.
  • Each element of birthdays contains between 7 and 50 characters, inclusive.
  • date and each element of birthdays follow the format described in the problem statement.
  • All dates are legal dates and neither date nor any date in birthdays is the 29th of February.

Examples

  1. "06/17"

    {"02/17 Wernie", "10/12 Stefan"}

    Returns: "10/12"

  2. "06/17"

    {"10/12 Stefan"}

    Returns: "10/12"

  3. "02/17"

    {"02/17 Wernie", "10/12 Stefan"}

    Returns: "02/17"

  4. "12/24"

    {"10/12 Stefan"}

    Returns: "10/12"

  5. "01/02"

    {"02/17 Wernie", "10/12 Stefan", "02/17 MichaelJordan", "10/12 LucianoPavarotti", "05/18 WilhelmSteinitz"}

    Returns: "02/17"

  6. "09/13"

    {"09/14 Loraine", "09/13 Gunther", "09/12 Gunar"}

    Returns: "09/13"

  7. "09/13"

    {"09/14 Loraine", "09/12 Gunar"}

    Returns: "09/14"

  8. "09/13"

    {"09/12 Gunar", "01/01 Emily"}

    Returns: "01/01"

  9. "01/30"

    {"10/12 Stefan", "01/31 Barris"}

    Returns: "01/31"

  10. "02/27"

    {"10/12 Stefan", "02/28 Carver"}

    Returns: "02/28"

  11. "03/30"

    {"10/12 Stefan", "03/31 Lowrance"}

    Returns: "03/31"

  12. "04/29"

    {"10/12 Stefan", "04/30 Maire"}

    Returns: "04/30"

  13. "05/30"

    {"10/12 Stefan", "05/31 Dalenna"}

    Returns: "05/31"

  14. "06/29"

    {"10/12 Stefan", "06/30 Katinka"}

    Returns: "06/30"

  15. "07/30"

    {"10/12 Stefan", "07/31 Jermaine"}

    Returns: "07/31"

  16. "08/30"

    {"10/12 Stefan", "08/31 Demetris"}

    Returns: "08/31"

  17. "09/29"

    {"10/12 Stefan", "09/30 Wadsworth"}

    Returns: "09/30"

  18. "10/30"

    {"10/12 Stefan", "10/31 Grayce"}

    Returns: "10/31"

  19. "11/29"

    {"10/12 Stefan", "11/30 Ian"}

    Returns: "11/30"

  20. "12/30"

    {"10/12 Stefan", "12/31 Derk"}

    Returns: "12/31"

  21. "12/26"

    {"07/12 Agneta"}

    Returns: "07/12"

  22. "10/15"

    {"04/27 Nataniel", "10/21 Avrom"}

    Returns: "10/21"

  23. "06/29"

    {"11/20 Dredi", "01/08 Karoly", "01/03 Fabian"}

    Returns: "11/20"

  24. "12/01"

    {"07/15 Lynn", "12/01 Christophorus", "12/22 Stefano", "04/08 Dahlia"}

    Returns: "12/01"

  25. "07/16"

    {"06/26 Gipsy", "05/20 Gilligan", "03/07 Meghann", "08/14 Emelita", "08/14 Perry"}

    Returns: "08/14"

  26. "11/28"

    {"08/30 Ashlan", "07/28 Edd", "11/23 Merrile", "02/20 Trista", "09/18 Junia", "08/10 Myrlene"}

    Returns: "02/20"

  27. "09/08"

    {"09/22 Helenelizabeth", "04/21 Nona", "03/16 Bunni", "01/28 Celinka", "01/13 Keen", "06/28 Humfried", "08/20 Jess"}

    Returns: "09/22"

  28. "04/11"

    {"04/21 Cassy", "11/26 Stephi", "08/03 Warren", "09/04 Carmelia", "11/16 Winfred", "11/06 Debbi", "06/29 Gisela", "09/12 Pavlov"}

    Returns: "04/21"

  29. "01/10"

    {"12/23 Christoper", "03/24 Caldwell", "09/08 Jessa", "10/06 Hale", "10/08 Lodovico", "11/25 Shari", "09/04 Brynn", "08/08 Tamara", "04/22 Marcel"}

    Returns: "03/24"

  30. "03/24"

    {"04/26 Mia", "07/17 Bran", "11/19 Hyacintha", "07/31 Doralyn", "03/12 Van", "03/12 Meghann", "03/29 Bent", "05/16 Heath", "12/03 Miguelita", "10/29 Cher"}

    Returns: "03/29"

  31. "11/22"

    {"11/05 Lelah", "07/18 Stillman", "05/09 Brooks", "05/23 Nolan", "06/04 Cyrillus", "07/02 Neville", "07/28 Goldie", "04/06 Rouvin", "01/03 Eal", "01/05 Christopher", "08/08 Hubey"}

    Returns: "01/03"

  32. "10/28"

    {"02/02 Lari", "08/31 Giacopo", "09/14 Justine", "10/07 Lucais", "06/21 Lisle", "04/22 Reilly", "07/01 Kippie", "07/02 Dalila", "10/05 Delly", "04/23 Janene", "11/29 Lanette", "07/03 Isac"}

    Returns: "11/29"

  33. "04/25"

    {"05/16 Bennett", "03/19 Garv", "05/08 Jaymee", "09/19 Ferrel", "05/22 Waiter", "02/17 Eudora", "11/08 Jim", "10/05 Shelden", "06/04 Michelle", "05/16 Barri", "09/12 Burty", "11/18 Fielding", "09/22 Bevin"}

    Returns: "05/08"

  34. "11/10"

    {"08/14 Brittaney", "12/19 Kyle", "12/31 Darice", "01/24 Bill", "04/24 Carmelle", "01/28 Rosalind", "11/11 Boote", "10/26 Correna", "03/03 Danika", "05/18 Clerc", "02/04 Merissa", "08/29 Corella", "03/10 Augustine", "08/21 Heywood"}

    Returns: "11/11"

  35. "03/04"

    {"09/24 Griswold", "02/06 Artair", "10/02 Brandyn", "06/15 Trstram", "05/31 Beulah", "01/12 Ruthanne", "04/02 Trevor", "11/06 Kippy", "05/31 Alethea", "03/02 Bernardine", "05/28 Turner", "10/16 Aluino", "02/03 Leshia", "08/19 Winfred", "08/03 Aleta"}

    Returns: "04/02"

  36. "12/02"

    {"06/11 Georgy", "02/02 Jolynn", "01/05 Bernette", "12/13 Leodora", "10/23 Baron", "09/04 Mannie", "06/03 Netti", "04/16 Merrili", "11/13 Lin", "10/05 Price", "09/12 Rourke", "03/26 Douglas", "08/24 Helyn", "12/21 Loydie", "03/19 Adriaens", "02/10 Dione"}

    Returns: "12/13"

  37. "03/18"

    {"01/06 Bayard", "08/26 Fanni", "08/23 Adams", "06/21 Selie", "05/29 Dorey", "09/23 Marlyn", "01/06 Ron", "08/24 Willette", "08/30 Jean", "09/27 Boot", "07/22 Nikolos", "12/13 Sybil", "03/15 Antoinette", "03/17 Rania", "03/02 Jermain", "06/15 Joshuah", "07/08 Ardine"}

    Returns: "05/29"

  38. "04/22"

    {"07/22 Lanni", "11/15 Diann", "06/12 Tricia", "12/31 Stesha", "06/05 Rae", "11/24 Georgi", "01/13 Shanon", "03/29 Erv", "09/10 Joly", "11/02 Winonah", "12/14 Margarete", "12/22 Tucky", "01/06 Taber", "09/19 Josh", "04/30 Rolland", "05/24 Blondelle", "09/02 Ed", "08/18 Montgomery"}

    Returns: "04/30"

  39. "11/10"

    {"05/11 Verne", "06/15 Sally", "06/11 Brigitte", "04/22 Maison", "07/25 Chiquita", "01/27 Demetris", "05/09 Phelia", "10/16 Talbert", "04/19 Stanislaw", "11/08 Millicent", "07/11 Darla", "04/28 Opalina", "05/16 Cary", "05/16 Shela", "05/19 Bob", "06/12 Tatum", "09/26 Letty", "01/31 Ximenez", "02/13 Liana"}

    Returns: "01/27"

  40. "01/17"

    {"07/13 Monroe", "10/23 Hervey", "11/30 Rowney", "05/10 Salvidor", "06/17 Welby", "05/19 Ettore", "05/28 Brigit", "04/24 Reinald", "01/13 Dilan", "01/12 Sergeant", "08/23 Lawry", "08/13 Marne", "12/09 Marley", "12/17 Roseanna", "04/13 Bartholemy", "05/18 Addison", "10/23 Leland", "04/23 Eden", "11/27 Haslett", "10/12 Flossie"}

    Returns: "04/13"

  41. "10/03"

    {"06/01 Russ", "06/02 Gerty", "08/09 Freddy", "02/03 Lorrie", "02/07 Alexandrina", "11/18 Marinna", "11/02 Arlen", "03/27 Marrilee", "04/16 Donnie", "05/31 Catharina", "01/28 Maureen", "04/08 Barbaraanne", "03/23 Onofredo", "02/24 Dominique", "08/02 Lefty", "10/29 Anett", "09/28 Marco", "12/02 Alon", "09/26 Bevvy", "04/12 Venita", "12/28 Ulrick"}

    Returns: "10/29"

  42. "12/28"

    {"05/15 Byram", "11/11 Marven", "07/19 Dorris", "12/31 Susan", "11/22 Gizela", "12/09 Wilbert", "08/29 Dermot", "07/10 Granthem", "10/17 Donall", "01/21 Ignacio", "04/23 Edouard", "05/27 Roseann", "03/14 Emmye", "08/02 Fredek", "10/16 Arlina", "08/12 Fenelia", "10/10 Sigismondo", "09/24 Starlene", "02/18 Bond", "07/10 Renee", "10/11 Alyss", "08/24 Nero"}

    Returns: "12/31"

  43. "05/29"

    {"12/07 Kennan", "12/20 Avril", "06/14 Trixie", "11/11 Yorker", "04/18 Reinold", "04/08 Kissee", "05/24 Minna", "06/25 Kenn", "03/15 Patin", "07/18 Fawnia", "02/09 Sacha", "07/18 Rosamund", "10/17 Jilly", "04/08 Josee", "07/14 Glad", "07/26 Persis", "04/30 Ardine", "07/02 Cate", "07/02 Stern", "03/23 Cooper", "07/11 Fania", "04/26 Ole", "04/03 Gerda"}

    Returns: "06/14"

  44. "09/30"

    {"02/28 Calley", "01/18 Brand", "06/10 Grier", "04/26 Idette", "11/29 Billi", "12/25 Valaree", "07/14 Fayette", "12/05 Clareta", "07/14 Jenine", "07/09 Fairlie", "10/30 Enid", "07/01 Redd", "11/24 Lorrie", "01/29 Zondra", "06/23 Donelle", "09/02 Faulkner", "02/14 Dennet", "06/01 Malchy", "06/23 Nichols", "08/23 Patrizio", "11/24 Mathian", "01/28 Lauren", "01/22 Bradford", "11/03 Stace"}

    Returns: "10/30"

  45. "02/20"

    {"03/29 Granville", "10/10 Averyl", "04/05 Letti", "08/03 Giovanni", "11/09 Edythe", "07/01 Kirbie", "01/17 Myrtice", "05/01 Elisha", "07/10 Hurley", "01/15 Eb", "09/06 Herve", "04/04 Bria", "05/18 Bernete", "12/07 Cody", "03/20 Nickolai", "02/11 Terri", "03/05 Craig", "08/14 Doyle", "02/13 Konstance", "09/03 Gladi", "02/25 Carilyn", "01/04 Alick", "11/15 Burty", "05/28 Courtnay", "09/27 Butch"}

    Returns: "02/25"

  46. "05/20"

    {"11/28 Shina", "05/28 Lauren", "07/13 Charin", "03/09 Colas", "11/20 Omar", "08/14 Mellisa", "12/31 Wilmar", "08/03 Colman", "12/10 Gardie", "02/06 Creigh", "01/24 Ketty", "03/13 Broddy", "05/15 Berne", "07/25 Duff", "10/05 Hanson", "02/26 Ricard", "06/15 Carter", "04/14 Thia", "03/30 Beverly", "06/14 Adrian", "09/07 Ruben", "12/26 Justus", "10/22 Birgit", "10/10 Paulo", "08/03 Carson", "05/26 Eda", "03/25 Elena", "11/04 Johnathan", "12/26 Corina", "02/21 Fairfax"}

    Returns: "05/26"

  47. "10/19"

    {"01/26 Dalenna", "08/11 Blane", "02/09 Elwin", "11/23 Pippy", "06/17 Garvy", "02/22 Reube", "07/10 Sandie", "04/14 Antonius", "07/13 Teresita", "03/09 Rianon", "08/23 Krystle", "03/29 Tabitha", "08/23 Abby", "10/25 Daryl", "11/20 Rollo", "08/27 Murry", "07/14 Tristam", "08/22 Chrotoem", "12/21 Paola", "06/14 Sacha", "01/28 Liana", "09/15 Alikee", "01/05 Clari", "05/24 Adrianna", "02/03 Imelda", "02/06 Idell", "07/08 Callida", "08/06 Arlen", "01/26 Dwayne", "05/05 Nessie", "02/17 Murdoch", "08/18 Cristiano", "06/07 Rafi", "10/14 Kennith", "01/28 Avictor"}

    Returns: "10/25"

  48. "06/02"

    {"11/30 Alta", "03/15 Corly", "06/06 Orrin", "01/13 Lucias", "01/04 Ami", "05/21 Addie", "05/18 Philip", "09/07 Cassandre", "06/25 Kettie", "08/08 Wendy", "07/11 Kleon", "08/23 Debor", "08/07 Melvin", "01/15 Westbrook", "10/28 Windy", "08/04 Tristan", "06/25 Krispin", "10/07 Kiley", "10/02 Bradley", "11/26 Susanetta", "09/08 Mellisent", "07/09 Elise", "07/23 Twyla", "12/03 Rosabel", "05/03 Mildred", "03/06 Julie", "09/16 Joann", "04/23 Faye", "11/15 Lyssa", "04/23 Perceval", "05/04 Curt", "10/25 Hanny", "11/18 Hewe", "04/09 Cammie", "02/27 Lemmy", "05/06 Hadleigh", "03/16 Ortensia", "03/15 Vinny", "06/24 Doralin", "01/26 Margalo"}

    Returns: "06/06"

  49. "03/21"

    {"01/21 Doro", "06/13 Alastair", "09/01 Sonnie", "11/03 Donn", "10/20 Almeda", "10/15 Court", "11/16 Leola", "06/17 Frederique", "12/09 Prudi", "01/27 Alex", "06/10 Clarette", "12/31 Dew", "09/29 Wat", "12/30 Marjy", "05/17 Lynne", "06/12 Cacilia", "09/04 Harriet", "02/22 Solomon", "04/07 Kennett", "06/01 Kenn", "10/17 Joy", "11/07 Carola", "08/15 Danya", "07/29 Aubert", "03/11 Benjamen", "02/06 Aloin", "03/15 Eliza", "05/12 Gayler", "07/22 Brandie", "03/29 Monica", "07/26 Olivie", "03/02 Brooks", "07/04 Elvin", "07/06 Georgine", "07/03 Norrie", "10/12 Kalle", "07/14 Johna", "12/05 Prudy", "05/18 Sybil", "03/29 Rolando", "04/26 Humbert", "07/18 Clay", "10/11 Wells", "01/21 Vonnie", "05/14 Shem"}

    Returns: "03/29"

  50. "12/08"

    {"05/11 Dorie", "02/18 Ailbert", "02/14 Elle", "01/01 Normand", "02/13 Timothy", "09/22 Scarlett", "07/15 Nevile", "02/19 Salvidor", "08/09 Vasilis", "12/11 Rasia", "02/15 Sidonnie", "10/13 Lou", "01/07 Ludvig", "08/19 Cherlyn", "10/28 Bobbye", "07/09 Andrei", "02/01 Michaella", "02/22 Therese", "06/06 Toddie", "07/05 Abie", "07/15 Grove", "11/09 Channa", "04/27 Darla", "07/09 Sandy", "07/12 Bob", "03/05 Malissa", "12/24 Georgeta", "02/16 Danila", "10/25 Arabel", "05/06 Benny", "02/13 Filberto", "05/08 Nonnah", "07/19 Jesse", "02/13 Tibold", "01/28 Archie", "09/17 Mohandas", "08/23 Jakie", "10/09 Rebecka", "10/19 Lorine", "11/11 Odille", "09/10 Englebert", "12/29 Noam", "05/06 Keri", "09/26 Brynne", "11/26 Belle", "08/28 Kippie", "02/04 Naoma", "06/17 Homerus", "01/18 Cly", "01/04 Ame"}

    Returns: "12/11"

  51. "02/10"

    { "02/13 klfdsdsa", "02/12 dsafdsafdsa" }

    Returns: "02/12"

  52. "01/02"

    { "01/02 Sree" }

    Returns: "01/02"

  53. "01/01"

    { "02/02 Bob" }

    Returns: "02/02"

  54. "01/30"

    { "01/05 Mike", "01/23 Kevin" }

    Returns: "01/05"

  55. "10/24"

    { "05/24 a", "01/24 b" }

    Returns: "01/24"

  56. "01/30"

    { "01/05 Brian", "01/23 Kevin" }

    Returns: "01/05"

  57. "01/02"

    { "02/17 wer", "10/12 ste", "02/17 mic", "10/12 luc", "05/18 wil" }

    Returns: "02/17"

  58. "06/01"

    { "07/15 John", "07/01 Justin" }

    Returns: "07/01"

  59. "12/24"

    { "02/15 h", "01/13 yo", "06/17 hey" }

    Returns: "01/13"

  60. "02/02"

    { "02/01 abc", "01/18 ace" }

    Returns: "01/18"

  61. "12/01"

    { "02/17 Z", "10/12 A", "02/18 Q", "10/12 P", "05/18 T" }

    Returns: "02/17"

  62. "07/15"

    { "07/31 A", "08/01 B" }

    Returns: "07/31"

  63. "01/01"

    { "03/03 Alex", "02/02 Bill" }

    Returns: "02/02"

  64. "12/24"

    { "10/12 James" }

    Returns: "10/12"

  65. "12/30"

    { "12/31 aa", "01/01 bb" }

    Returns: "12/31"

  66. "01/01"

    { "02/02 Foo" }

    Returns: "02/02"

  67. "05/02"

    { "05/03 Ashish" }

    Returns: "05/03"

  68. "02/02"

    { "05/15 hell", "05/14 ihope", "05/01 thisworks" }

    Returns: "05/01"

  69. "02/10"

    { "02/13 klfdsdsa", "02/12 dsafdsafdsa" }

    Returns: "02/12"

  70. "01/02"

    { "01/02 Sree" }

    Returns: "01/02"

  71. "01/01"

    { "02/02 Bob" }

    Returns: "02/02"

  72. "01/30"

    { "01/05 Mike", "01/23 Kevin" }

    Returns: "01/05"

  73. "10/24"

    { "05/24 a", "01/24 b" }

    Returns: "01/24"

  74. "01/30"

    { "01/05 Brian", "01/23 Kevin" }

    Returns: "01/05"

  75. "01/02"

    { "02/17 wer", "10/12 ste", "02/17 mic", "10/12 luc", "05/18 wil" }

    Returns: "02/17"

  76. "06/01"

    { "07/15 John", "07/01 Justin" }

    Returns: "07/01"

  77. "12/24"

    { "02/15 h", "01/13 yo", "06/17 hey" }

    Returns: "01/13"

  78. "02/02"

    { "02/01 abc", "01/18 ace" }

    Returns: "01/18"

  79. "12/01"

    { "02/17 Z", "10/12 A", "02/18 Q", "10/12 P", "05/18 T" }

    Returns: "02/17"

  80. "07/15"

    { "07/31 A", "08/01 B" }

    Returns: "07/31"

  81. "01/01"

    { "03/03 Alex", "02/02 Bill" }

    Returns: "02/02"

  82. "12/24"

    { "10/12 James" }

    Returns: "10/12"

  83. "12/30"

    { "12/31 aa", "01/01 bb" }

    Returns: "12/31"

  84. "01/01"

    { "02/02 Foo" }

    Returns: "02/02"

  85. "05/02"

    { "05/03 Ashish" }

    Returns: "05/03"

  86. "02/02"

    { "05/15 hell", "05/14 ihope", "05/01 thisworks" }

    Returns: "05/01"


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: