FastPrepNext Upcoming Birthday
Problems/Next Upcoming Birthday

Next Upcoming Birthday

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The task asks who has the closest birthday still to come, given records for people that list a name, the parents and a date of birth. It was the design part of Round 1 in the author's second Adobe loop (Noida, January 2026), after an interval question; the report states it in one line and calls it an interface.

The report gives no interface, rules or examples. Here you answer a list of query dates from names and birth dates. A birthday on the query date counts, the search wraps into the next year, ties go to the alphabetically first name, and nobody is born on February 29. The parents field does not affect the answer, so it is left out of the input. The examples are our own.

The judged task matches the report at about 60%.

A family record keeps each person's name and birth date: person i is names[i], born on birthDates[i]. Build the lookup for the next upcoming birthday: for each date in queryDates, return the name of the person whose next birthday comes first.

  • A person's birthday falls on the same month and day every year.
  • A birthday on the query date itself counts as the next birthday.
  • If every birthday has already passed in the query's year, look at the next year.
  • If several people share the soonest birthday, return the name that comes first alphabetically.

Return one name per query, in the same order as queryDates.

Function

nextBirthdays(names: String[], birthDates: String[], queryDates: String[]) → String[]

Examples

Example 1

names = ["Maya","Arjun","Lena"]birthDates = ["1990-03-15","1985-11-02","2001-07-30"]queryDates = ["2026-04-01","2026-11-02","2026-12-25"]return = ["Lena","Arjun","Maya"]

On 2026-04-01 the next birthdays are Lena on 2026-07-30, Arjun on 2026-11-02 and Maya on 2027-03-15, so Lena is first. On 2026-11-02 it is Arjun's birthday that very day, which counts. On 2026-12-25 everyone's birthday has passed for the year, and the earliest one next year is Maya's on 2027-03-15.

Example 2

names = ["Zoe","Adam"]birthDates = ["1999-05-05","2003-05-05"]queryDates = ["2026-05-06"]return = ["Adam"]

Both were born on May 5, which was the day before the query, so both next birthdays are on 2027-05-05. The tie goes to the name that comes first alphabetically, "Adam".

Example 3

names = ["Omar"]birthDates = ["1970-02-28"]queryDates = ["2028-02-29"]return = ["Omar"]

2028 is a leap year and the query is February 29, one day after Omar's birthday. His next birthday is 2029-02-28.

Constraints

  • 1 <= names.length <= 1000 and birthDates.length == names.length
  • 1 <= queryDates.length <= 1000
  • Every name is different and is one capital letter followed by 1 to 9 lowercase letters.
  • Every date is a real calendar date written as "YYYY-MM-DD".
  • Birth years are from 1900 to 2025, and nobody is born on February 29.
  • Query years are from 2000 to 2100, and every query date is on or after every birth date.

More Adobe problems

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
All Adobe interview questionsSee Adobe hiring insights
Saved
public String[] nextBirthdays(String[] names, String[] birthDates, String[] queryDates) {
    // Write your code here.
}
Checking account…