Skip to content

Commit 9415b21

Browse files
committed
Add solution #1185
1 parent 169b6d8 commit 9415b21

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1,170 LeetCode solutions in JavaScript
1+
# 1,171 LeetCode solutions in JavaScript
22

33
[https://leetcodejavascript.com](https://leetcodejavascript.com)
44

@@ -918,6 +918,7 @@
918918
1177|[Can Make Palindrome from Substring](./solutions/1177-can-make-palindrome-from-substring.js)|Medium|
919919
1178|[Number of Valid Words for Each Puzzle](./solutions/1178-number-of-valid-words-for-each-puzzle.js)|Hard|
920920
1184|[Distance Between Bus Stops](./solutions/1184-distance-between-bus-stops.js)|Easy|
921+
1185|[Day of the Week](./solutions/1185-day-of-the-week.js)|Easy|
921922
1189|[Maximum Number of Balloons](./solutions/1189-maximum-number-of-balloons.js)|Easy|
922923
1200|[Minimum Absolute Difference](./solutions/1200-minimum-absolute-difference.js)|Easy|
923924
1206|[Design Skiplist](./solutions/1206-design-skiplist.js)|Hard|

solutions/1185-day-of-the-week.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* 1185. Day of the Week
3+
* https://leetcode.com/problems/day-of-the-week/
4+
* Difficulty: Easy
5+
*
6+
* Given a date, return the corresponding day of the week for that date.
7+
*
8+
* The input is given as three integers representing the day, month and year respectively.
9+
*
10+
* Return the answer as one of the following values {"Sunday", "Monday", "Tuesday", "Wednesday",
11+
* "Thursday", "Friday", "Saturday"}.
12+
*/
13+
14+
/**
15+
* @param {number} day
16+
* @param {number} month
17+
* @param {number} year
18+
* @return {string}
19+
*/
20+
var dayOfTheWeek = function(day, month, year) {
21+
return ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][
22+
new Date(year, month - 1, day).getDay()
23+
];
24+
};

0 commit comments

Comments
 (0)