Skip to content

Commit 3bca302

Browse files
authored
Create leap_year.py
1 parent c672b38 commit 3bca302

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

leap_year.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
"""
3+
@param n: a number represent year
4+
@return: whether year n is a leap year.
5+
"""
6+
def isLeapYear(self, n):
7+
# write your code here
8+
if n % 400 == 0:
9+
return True
10+
else:
11+
return (n % 4 == 0) and (n % 100 != 0)
12+
13+
# easy: https://www.lintcode.com/problem/leap-year

0 commit comments

Comments
 (0)