Skip to content

Latest commit

 

History

History

number-of-days-in-a-month

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

< Previous                  Next >

Given a year Y and a month M, return how many days there are in that month.

 

Example 1:

Input: Y = 1992, M = 7
Output: 31

Example 2:

Input: Y = 2000, M = 2
Output: 29

Example 3:

Input: Y = 1900, M = 2
Output: 28

 

Note:

  1. 1583 <= Y <= 2100
  2. 1 <= M <= 12

Related Topics

[Math]

Hints

Hint 1 Does February have 28 days or 29 days?
Hint 2 Think of Leap years.