Day of the Week - Problem
Given a date, return the corresponding day of the week for that date.
The input is given as three integers representing the day, month and year respectively.
Return the answer as one of the following values: {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}.
Note: January 1, 1971 was a Friday.
Input & Output
Example 1 — Basic Case
$
Input:
day = 31, month = 12, year = 1999
›
Output:
Friday
💡 Note:
December 31, 1999 was a Friday. We can verify this by counting days from January 1, 1971 or using Zeller's formula.
Example 2 — Leap Year
$
Input:
day = 29, month = 2, year = 2000
›
Output:
Tuesday
💡 Note:
February 29, 2000 was a Tuesday. Year 2000 is a leap year (divisible by 400).
Example 3 — Reference Date
$
Input:
day = 1, month = 1, year = 1971
›
Output:
Friday
💡 Note:
January 1, 1971 was a Friday as given in the problem statement.
Constraints
- 1 ≤ day ≤ 31
- 1 ≤ month ≤ 12
- 1971 ≤ year ≤ 2100
- The given date is guaranteed to be valid
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code