Talentd
FleetCode

1118. Number of Days in a Month

Easy59.4% acceptance1 companyPremium elsewhere, free here

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

Example 1:

Input: year = 1992, month = 7
Output: 31

Example 2:

Input: year = 2000, month = 2
Output: 29

Example 3:

Input: year = 1900, month = 2
Output: 28

Constraints:

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

Asked at 1 company

Topics

Hints open one at a time

Hint 1
Does February have 28 days or 29 days?
Hint 2
Think of Leap years.
4:01
Still stuck?Read the written solution, or watch a walkthrough.
Open solution
Loading editor…
1class Solution:
2 def solve(self):
3 pass
4
Starter codePython 3Spaces: 4
Examples
Input
1992
7
Input
2000
2
Input
1900
2
Your code is saved on this device.Solution