Array ( [0] => [1] => questions [2] => Basic [3] => Leap-Year )
Given a Number N. You have to find the given number is a leap year or not.
First line contains one integers.
Print Yes if it is leap year else No.
2024
Yes
2000
Yes
2101
No
Login to see Discussion
Step-i) if remainder of the division of given year by 4 is 0 go to next step else return "No"
Step-ii) if remainder of the division of given year by 100 is 0 go to next step else return "Yes"
Step-iii) if remainder of the division of given year by 400 is 0 return "Yes" else return "No"
Time Complexity: O(1)
Space Complexity: O(1)
Note :
Let us know if you can come up with a better approach, mail us at support@theinquisitive.in Your approach will be reviewed and posted with credits to you.
Login to see Solution