Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit339da72

Browse files
refactor 1185
1 parented7e540 commit339da72

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

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

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,14 @@
11
packagecom.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
publicclass_1185 {
264
publicstaticclassSolution1 {
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
publicStringdayOfTheWeek(intday,intmonth,intyear) {
3513
String[]daysInTheWeek =newString[]{"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
3614
int[]daysInTheMonth =newint[]{31,28,31,30,31,30,31,31,30,31,30,31};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp