Google Interview Question
Company: Google
Role: unknown
Interview Stage: unknown
Location: unknown
Year: unknown
Original Post Content:
Design an algorithm to manage birthday reminders for your family tree. You are given a genealogical tree representing your direct ancestors, rooted at you. Each person in the tree has a name and birthday. Your task is to implement a function alarmNextBirthday() that sets an alarm for the next upcoming birthday in the family tree. After that birthday passes, alarmNextBirthday() should be called again to set an alarm for the subsequent upcoming birthday, and so on. Given:
class Person {
String name;
int birthdayMonth;
int birthdayDayOfTheMonth;
Person parentA;
Person parentB;
public Person(String name, int birthdayMonth, int birthdayDayOfTheMonth, Person parentA, Person parentB) {
this.name = name;
this.birthdayM birthdayMonth;
this.birthdayDayOfTheM birthdayDayOfTheMonth;
this.parentA = parentA;
this.parentB = parentB;
}
}