Skip to content

Commit 8c22053

Browse files
committed
Add Solution.java for 1185.Day of the Week
1 parent 1757d96 commit 8c22053

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
3+
private final String[] week = new String[]{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
4+
5+
public String dayOfTheWeek(int day, int month, int year) {
6+
// Zeller Formula
7+
if(month == 1 || month == 2) {
8+
month += 12;
9+
year -= 1;
10+
}
11+
return week[(day +2*month+3*(month+1)/5+year+year/4-year/100+year/400+1) % 7];
12+
}
13+
}

0 commit comments

Comments
 (0)