Count All Valid Pickup and Delivery Options

Given n orders, each order consists of a pickup and a delivery service.

Count all valid pickup/delivery possible sequences such that delivery(i) is always after pickup(i).

Since the answer may be too large, return it modulo 10^9 + 7.

Example 1
Inputn = 1
Output1
Unique order (P1, D1), so Delivery 1 is always after Pickup 1.
Example 2
Inputn = 2
Output6
There are 6 valid orders; (P1, D2, P2, D1) is invalid because Pickup 2 is after Delivery 2.

Constraints

  • 1 <= n <= 500

Asked at 3 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate