← Unit 2 · all exercises
Saved in this browser only

Leap year

A year is a leap year when it divides by 4, except that years dividing by 100 are not, unless they also divide by 400. So 2000 is a leap year and 1900 is not.

boolean isLeap(int year)

Solution.java
Loading editor…
Results

Examples

  • isLeap(2024) → true
  • isLeap(2023) → false

There are also 4 hidden tests you can't see. Solve the problem, not the examples.