0

In an interview I was asked this question, You are the college principal and want to send a birthday wish to all the students who have their birthdays today. How do you implement this?

I said I will go with a Multi Hashset of dates where chaining is used so that each date has multiple studentIDs.(Each date will map to multiple students). But is there anything better that can be done?

Shubham Patel
  • 133
  • 2
  • 7
  • 1
    Rule 1 during interviews: if something is ambiguous, ask about it. In this question there is one big unknown, namely: what other operations are performed on students? If the only operations are addition (and there is no need to check for duplicates) and sending birthday wish, then the optimal solution is an array of 366 lists. Depending on other operations it may be a terrible data structure. –  Jul 31 '19 at 03:48
  • If the only requirement is to add students and send wishes on a particular day, your approach of having hash table of dates with student lists per day looks reasonable. – karastojko Jul 31 '19 at 06:20

0 Answers0