Junior

The Number of Users That Are Eligible for Discount

You are given purchase records represented by three parallel arrays: user_ids, time_stamps, and amounts, where the ith purchase was made by user user_ids[i] on date time_stamps[i] for amounts[i].

A user is eligible for a discount if they made at least one purchase such that:

  • The purchase date is between start_date and end_date, inclusive.
  • The purchase amount is greater than or equal to min_amount.

Return the number of distinct users who are eligible for the discount.

Example 1
Inputuser_ids = [1,1,2,2,3,3], time_stamps = ["2022-04-20","2022-04-25","2022-04-20","2022-04-25","2022-04-20","2022-04-25"], amounts = [1000,1000,2000,3000,4000,5000], start_date = "2022-04-20", end_date = "2022-04-25", min_amount = 3000
Output2
Users 2 and 3 each have at least one purchase between the given dates with amount at least 3000.
Example 2
Inputuser_ids = [1,2,2,3], time_stamps = ["2022-01-01","2022-01-05","2022-02-01","2022-01-10"], amounts = [50,200,500,150], start_date = "2022-01-01", end_date = "2022-01-31", min_amount = 150
Output2
Users 2 and 3 qualify from purchases in January with amounts at least 150, while the February purchase is outside the date range.

Constraints

  • 1 <= user_ids.length == time_stamps.length == amounts.length <= 10^5
  • 1 <= user_ids[i] <= 10^5
  • 0 <= amounts[i], min_amount <= 10^9
  • time_stamps[i], start_date, and end_date are valid dates in YYYY-MM-DD format
  • start_date <= end_date

Asked at 1 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