The Day of the Week interview question asks you to calculate the correct day name (e.g., "Monday") for a given date (day, month, year). You are typically given a reference date (like Jan 1, 1971, which was a Friday) and you need to determine the day for any date after that. This Day of the Week coding problem is a test of modular arithmetic and calendar logic.
Google uses this to check if you can handle multiple logical constraints (leap years, varying month lengths) and apply mathematical formulas. It tests your attention to detail regarding the Gregorian calendar rules and your ability to map a large range of days to a small set of outcomes (7 days) using the modulo operator.
This utilizes the Math interview pattern.
Target: Jan 3, 1971.
Memorize the "30 days hath September..." rhyme or store month lengths in an array. Handling leap years correctly is the most important part of this problem—always remember the "century rule" (100 and 400).
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Confusing Number | Easy | Solve | |
| Find the Key of the Numbers | Easy | Solve | |
| Construct the Rectangle | Easy | Solve | |
| Count the Digits That Divide a Number | Easy | Solve | |
| A Number After a Double Reversal | Easy | Solve |