MeetCode
Check leap year
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Run
Submit
Dark
Problem Statement
Solutions
Submissions
Check leap year
Easy
Java
Control Flow
18 views
Explanation
Complexity
Problem Statement
Task: return true if year is leap year using correct rules (divisible by 400, or divisible by 4 but not 100).
Input Format
An integer year.
Output Format
true if leap year, otherwise false.
Example
Input
2000
Output
true
Constraints
• year ≥ 1
• Use correct leap year rules
Concept Explanation
A year is a leap year if:
• It is divisible by 400, OR
• It is divisible by 4 but not divisible by 100.
Step-by-Step Explanation
1.Read integer year.
2.If year % 400 == 0, return true.
3.Else if year % 4 == 0 and year % 100 != 0, return true.
4.Else return false.
Concept Explanation
A year is a leap year if:
• It is divisible by 400, OR
• It is divisible by 4 but not divisible by 100.
Step-by-Step Explanation
1.Read integer year.
2.If year % 400 == 0, return true.
3.Else if year % 4 == 0 and year % 100 != 0, return true.
4.Else return false.
Input / Output Format
Input Format
An integer year.
Output Format
true if leap year, otherwise false.
Constraints
• year ≥ 1
• Use correct leap year rules
Examples
Input:
2000
Output:
true
Example Solution (Public)
Java
static boolean isLeap(int y){return (y%400==0)||((y%4==0)&&(y%100!=0));}
Official Solution Code
Wrap
Copy
static boolean isLeap(int y){return (y%400==0)||((y%4==0)&&(y%100!=0));}
Please
login
to submit solutions.
Editor
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Test Cases
Output
Submission Result
Input
2000
Expected Output
true
Compile Output
Error
Output
Please
login
to submit solutions.