Leap Year Checker - Problem
Given a year, determine whether it is a leap year or not.
A leap year is a year that is divisible by 4, except for years that are divisible by 100, unless they are also divisible by 400.
Rules for leap years:
- If the year is divisible by 4, it might be a leap year
- If the year is divisible by 100, it is not a leap year
- If the year is divisible by 400, it is a leap year
Return true if the year is a leap year, false otherwise.
Input & Output
Example 1 — Leap Year (Divisible by 400)
$
Input:
year = 2000
›
Output:
true
💡 Note:
2000 is divisible by 400, so it's a leap year despite being divisible by 100
Example 2 — Not Leap Year (Century Year)
$
Input:
year = 1900
›
Output:
false
💡 Note:
1900 is divisible by 100 but not by 400, so it's not a leap year
Example 3 — Leap Year (Regular)
$
Input:
year = 2024
›
Output:
true
💡 Note:
2024 is divisible by 4 and not by 100, so it's a leap year
Constraints
- 1 ≤ year ≤ 3000
- Year is a positive integer
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code