585. Number of Days in a Month

Given a year year and a month month, return the number of days in that month.

Example 1:

Input: year = 2024, month = 1

Output: 31

Example 2:

Input: year = 2023, month = 2

Output: 28

Now Your Turn!

Pick the correct output for the given input

Input: year = 2020, month = 2

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1583 <= year <= 2100
  • 1 <= month <= 12

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

0
class Solution {
public:
int numberOfDays(int year, int month) {
// Your code goes here
}
};
Test Case

Input:

Month
Year