isLeapYear
Given a year, return true if it is a leap year, otherwise return false. A leap year is a year which is divisible by 4, except for end-of-century years, which must be divisible by 400.
Examples
isLeapYear(2000) → true
isLeapYear(1900) → false
isLeapYear(2024) → true
Starter code
function isLeapYear(year) {
}
Complexity of the optimal solution
Time O(1), space O(1). The solution consists of a fixed number of arithmetic and boolean operations. The complexity is constant regardless of the input year.