Skip to content

Commit 339da72

Browse files
refactor 1185
1 parent ed7e540 commit 339da72

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

src/main/java/com/fishercoder/solutions/_1185.java

+2-24
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,14 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 1185. Day of the Week
5-
*
6-
* Given a date, return the corresponding day of the week for that date.
7-
* The input is given as three integers representing the day, month and year respectively.
8-
* Return the answer as one of the following values {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}.
9-
*
10-
* Example 1:
11-
* Input: day = 31, month = 8, year = 2019
12-
* Output: "Saturday"
13-
*
14-
* Example 2:
15-
* Input: day = 18, month = 7, year = 1999
16-
* Output: "Sunday"
17-
*
18-
* Example 3:
19-
* Input: day = 15, month = 8, year = 1993
20-
* Output: "Sunday"
21-
*
22-
* Constraints:
23-
* The given dates are valid dates between the years 1971 and 2100.
24-
* */
253
public class _1185 {
264
public static class Solution1 {
275
/**
286
* Time: O(1)
297
* Space: O(1)
30-
*
8+
* <p>
319
* Plain and simple algorithm:
3210
* based on the fact that 1/1/1971 is a Friday and calculate the given day.
33-
* */
11+
*/
3412
public String dayOfTheWeek(int day, int month, int year) {
3513
String[] daysInTheWeek = new String[]{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
3614
int[] daysInTheMonth = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

0 commit comments

Comments
 (0)