Back to problems

Count Months Whose First Day Is Sunday

Algorithm · Walmart Labs · Medium

Given two years startYear and endYear with startYear <= endYear, return the number of calendar months in that inclusive year range whose first day is a Sunday. A month is counted if its first day falls on Sunday, considering every month from January of startYear through December of endYear. Use the proleptic Gregorian calendar. A year is a leap year when it is divisible by 4, except that a year divisible by 100 is a leap year only when it is also divisible by 400. You may…

Checking your access…