Leap Year Check

Easy~10 min

Given an integer year, determine if it is a leap year.

A year is a leap year if:

  • It is divisible by 4 AND not divisible by 100, OR
  • It is divisible by 400.

Return true if the year is a leap year, and false otherwise.

Examples

Example 1
Input: year = 2024
Output: true
Explanation: 2024 is divisible by 4 and not divisible by 100, so it is a leap year.
Example 2
Input: year = 1900
Output: false
Explanation: 1900 is divisible by 100 but not by 400, so it is not a leap year.
Example 3
Input: year = 2000
Output: true
Explanation: 2000 is divisible by 400, so it is a leap year.

Constraints

  • 1 <= year <= 10^6
Code
Ctrl+EnterRun|Ctrl+⇧+EnterSubmit
Output

Run your code to see results

Use Cmd+Enter to run