File tree 2 files changed +29
-1
lines changed
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 1
- # 1,253 LeetCode solutions in JavaScript
1
+ # 1,254 LeetCode solutions in JavaScript
2
2
3
3
[ https://leetcodejavascript.com ] ( https://leetcodejavascript.com )
4
4
1033
1033
1356|[ Sort Integers by The Number of 1 Bits] ( ./solutions/1356-sort-integers-by-the-number-of-1-bits.js ) |Easy|
1034
1034
1357|[ Apply Discount Every n Orders] ( ./solutions/1357-apply-discount-every-n-orders.js ) |Medium|
1035
1035
1358|[ Number of Substrings Containing All Three Characters] ( ./solutions/1358-number-of-substrings-containing-all-three-characters.js ) |Medium|
1036
+ 1359|[ Count All Valid Pickup and Delivery Options] ( ./solutions/1359-count-all-valid-pickup-and-delivery-options.js ) |Hard|
1036
1037
1360|[ Number of Days Between Two Dates] ( ./solutions/1360-number-of-days-between-two-dates.js ) |Easy|
1037
1038
1365|[ How Many Numbers Are Smaller Than the Current Number] ( ./solutions/1365-how-many-numbers-are-smaller-than-the-current-number.js ) |Easy|
1038
1039
1366|[ Rank Teams by Votes] ( ./solutions/1366-rank-teams-by-votes.js ) |Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 1359. Count All Valid Pickup and Delivery Options
3
+ * https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options/
4
+ * Difficulty: Hard
5
+ *
6
+ * Given n orders, each order consists of a pickup and a delivery service.
7
+ *
8
+ * Count all valid pickup/delivery possible sequences such that delivery(i) is always after
9
+ * of pickup(i).
10
+ *
11
+ * Since the answer may be too large, return it modulo 10^9 + 7.
12
+ */
13
+
14
+ /**
15
+ * @param {number } n
16
+ * @return {number }
17
+ */
18
+ function countOrders ( n ) {
19
+ const MOD = 1e9 + 7 ;
20
+ let result = 1 ;
21
+
22
+ for ( let i = 1 ; i <= n ; i ++ ) {
23
+ result = ( result * ( 2 * i - 1 ) * i ) % MOD ;
24
+ }
25
+
26
+ return result ;
27
+ }
You can’t perform that action at this time.
0 commit comments