Given a date, return the corresponding day of the week for that date.

The input is given as three integers representing the day, month and year respectively.

Return the answer as one of the following values&nbsp;{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}.

&nbsp;
Example 1:

Input: day = 31, month = 8, year = 2019
Output: "Saturday"


Example 2:

Input: day = 18, month = 7, year = 1999
Output: "Sunday"


Example 3:

Input: day = 15, month = 8, year = 1993
Output: "Sunday"


&nbsp;
Constraints:


	The given dates are valid dates between the years 1971 and 2100.


class Solution:
    def dayOfTheWeek(self, day: int, month: int, year: int) -> str:
        LOWEST_DAY, LOWEST_MONTH, LOWEST_YEAR, DAY = 1, 1, 1971, 5
        DAYS = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")

        difference = self.daysBetweenDates((LOWEST_DAY, LOWEST_MONTH, LOWEST_YEAR), (day, month, year))
        return DAYS[(difference + DAY) % 7]

    def daysBetweenDates(self, date1: tuple, date2: tuple) -> int:
        LOWEST_YEAR = 1971

        def daysSinceLowest(date: tuple) -> int:
            day, month, year = date

            isLeapYear = lambda x: 1 if (x % 4 == 0 and x % 100 != 0) or x % 400 == 0 else 0

            days: int = 0
            # days between the LOWEST_YEAR and year
            days += 365 * (year - LOWEST_YEAR) + sum(map(isLeapYear, range(LOWEST_YEAR, year)))
            # days between year and exact date
            daysInMonth = (31, 28 + isLeapYear(year), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
            days += sum(daysInMonth[:month - 1]) + day
            return days

        return abs(daysSinceLowest(date1) - daysSinceLowest(date2))
class Solution {
    public String dayOfTheWeek(int day, int month, int year) {
        String[] week = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
        year--;
        int total = (year/4)*366+(year-year/4)*365;
        int[] months = {31,28,31,30,31,30,31,31,30,31,30,31};
        year++;
        if(year%4==0 && year!=2100){
            months[1]++;
        }
        for(int i=0;i<month-1;i++){
            total+= months[i];
        }
        total +=day;
        // for(int i:months){
        //     System.out.print(i+" ");
        // }
        // System.out.println();
        return week[(total-1)%7];
        
    }
}
class Solution {
public:
    int daysOfMonth[2][12] = {
        31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
        31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
    };
    string weekName[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
    bool isleapyear(int year)
    {
        return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
    }
    int daystill1971(int year, int month, int day)
    {
        int count = 0;
        int year1 = 1970, month1 = 1, day1 = 1;
        while (year1 != year)
        {
            bool b = isleapyear(year1);
            if (b) count += 366;
            else count += 365;
            year1++;
        }
        int b = isleapyear(year1) ? 0 : 1;
        for (int i = 0; i < month - 1; i++) count += daysOfMonth[b][i];
        count += day - 1;
        return count;
    }
    string dayOfTheWeek(int day, int month, int year) {
        int days1 = daystill1971(2019, 9, 8);//today(2019,9,8) is Sunday
        int days2 = daystill1971(year, month, day);
        int days = (((days2 - days1) % 7) + 7) % 7;//Number of days off
        return weekName[days];
    }
};
/**
 * @param {number} day
 * @param {number} month
 * @param {number} year
 * @return {string}
 */
var dayOfTheWeek = function(day, month, year) {
    var map = {
        0: "Sunday",
        1: "Monday",
        2: "Tuesday",
        3: "Wednesday",
        4: "Thursday",
        5: "Friday",
        6: "Saturday"
    };
    var date = new Date(`${month}/${day}/${year}`);
    return map[date.getDay()];
};
Day of the Week