0
Leetcode Problem 1185. Day of the Week
1185. Day of the Week
AI Mock Interview
Leetcode Solutions
Using Zeller's Congruence
Solution Idea
Algorithm Steps
Code Implementation
Complexity Analysis
Create an array
weekDay
with the days of the week starting from Saturday (as per Zeller's Congruence).
If the month is January or February, increment the month by 12 and decrement the year by 1.
Calculate the values of
k
(year of the century),
j
(zero-based century),
q
(day of the month), and
m
(month).
Apply Zeller's Congruence formula to find the day index.
Return the day of the week using the calculated index.
Iterative Calculation of Days
Ask Question
Programming Language
Purpose:
General Question
Debug My Code
image/screenshot of info
(optional)
[+]
Full Screen
Loading...
Get Answer
Suggested Answer
Answer
Full Screen
Copy Answer Code
Loading...