Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4657884

Browse files
committedApr 12, 2025
Add solution #1359
1 parent d675f26 commit 4657884

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-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,253 LeetCode solutions in JavaScript
1+
# 1,254 LeetCode solutions in JavaScript
22

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

@@ -1033,6 +1033,7 @@
10331033
1356|[Sort Integers by The Number of 1 Bits](./solutions/1356-sort-integers-by-the-number-of-1-bits.js)|Easy|
10341034
1357|[Apply Discount Every n Orders](./solutions/1357-apply-discount-every-n-orders.js)|Medium|
10351035
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|
10361037
1360|[Number of Days Between Two Dates](./solutions/1360-number-of-days-between-two-dates.js)|Easy|
10371038
1365|[How Many Numbers Are Smaller Than the Current Number](./solutions/1365-how-many-numbers-are-smaller-than-the-current-number.js)|Easy|
10381039
1366|[Rank Teams by Votes](./solutions/1366-rank-teams-by-votes.js)|Medium|
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
}

0 commit comments

Comments
 (0)
Please sign in to comment.