Leap year

You are given a year in the form of an integer 'N', and your task is to check whether the given year is a leap year or not.

Note:

1) A year is said to be a leap year if it has 366 days. Normal years have 365 days.

2) The integer 'N' does not contain any leading zeros.
Input Format:
The first line of the input contains an integer T denoting the number of test cases.

The first and the only line of each test case contains an integer 'N', denoting the year.
Output Format:
For each test case, return “Yes” if the input year is a leap year otherwise “No”.
Note:
You do not need to print anything, it has already been taken care of. Just implement the given function.
Constraints:
1 <= T <= 100
1000 <= N <= 9999

Time limit: 1 sec
CodingNinjas
author
2y

I simply applied logic for checking the year.

CodingNinjas
author
2y
Basic Maths
  • We can make the following observations regarding every leap year:
  • If the year is divisible by 400 then it is a leap year. For example, 2000 was a leap year and it is divisible by 400.
  • If the ...read more
Mridul Sharma
1y

mathematically if the year is divisible by 4 its a leap year.

N/4 =lrap year

Add answer anonymously...
TCS Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter