Google Interview Question

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2025-05-27Added By Anonymous
Source: Link

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;

1public Person(String name, int birthdayMonth, int birthdayDayOfTheMonth, Person parentA, Person parentB) { 2 this.name = name; 3 this.birthdayMonth = birthdayMonth; 4 this.birthdayDayOfTheMonth = birthdayDayOfTheMonth; 5 this.parentA = parentA; 6 this.parentB = parentB; 7}

}


Comments