101
0/304
Loading content...
A commerce platform stores purchase events and a one-row discount policy.
Table: Purchases
Table: DiscountPolicy
Eligibility definition: A user is discount-eligible if they have at least one purchase that satisfies both conditions:
Important time rule:
Task: Return one row with one column user_cnt representing the number of distinct eligible users.
Supported submission environments:
Purchases:
| user_id | time_stamp | amount |
|---------|----------------------|--------|
| 1 | 2022-04-20 09:03:00 | 4416 |
| 2 | 2022-03-19 19:24:02 | 678 |
| 3 | 2022-03-18 12:03:09 | 4523 |
| 3 | 2022-03-30 09:43:42 | 626 |
DiscountPolicy:
| start_date | end_date | min_amount |
|------------|------------|------------|
| 2022-03-08 | 2022-03-20 | 1000 |[
{"user_cnt": 1}
]Only user 3 has a purchase meeting both rules. User 1 is outside the window, and user 2 is below the threshold.
Purchases:
| user_id | time_stamp | amount |
|---------|----------------------|--------|
| 10 | 2024-10-10 00:00:00 | 700 |
| 10 | 2024-10-12 00:00:00 | 900 |
| 20 | 2024-10-12 00:00:01 | 1200 |
| 30 | 2024-10-09 23:59:59 | 1200 |
DiscountPolicy:
| start_date | end_date | min_amount |
|------------|------------|------------|
| 2024-10-10 | 2024-10-12 | 700 |[
{"user_cnt": 1}
]The interval includes both boundary midnights, so user 10 qualifies. User 20 is one second after the upper bound and user 30 is before the lower bound.
Purchases:
[]
DiscountPolicy:
| start_date | end_date | min_amount |
|------------|------------|------------|
| 2023-01-01 | 2023-12-31 | 500 |[
{"user_cnt": 0}
]No purchases means no eligible users.
Constraints