bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 1185. Day of the Week

1185. Day of the Week

Leetcode Solutions

Using Zeller's Congruence

  1. Create an array weekDay with the days of the week starting from Saturday (as per Zeller's Congruence).
  2. If the month is January or February, increment the month by 12 and decrement the year by 1.
  3. Calculate the values of k (year of the century), j (zero-based century), q (day of the month), and m (month).
  4. Apply Zeller's Congruence formula to find the day index.
  5. Return the day of the week using the calculated index.
UML Thumbnail

Iterative Calculation of Days

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...