Hone logo
Hone
Problems

Identifying Dormant Customers

This challenge focuses on identifying customers who have shown interest by visiting a store or website but have not made any purchases. This is a common business need to understand customer engagement, identify potential marketing targets, and optimize strategies for converting visitors into buyers.

Problem Description

You are given two datasets: one containing records of customer visits and another containing records of customer transactions. Your task is to identify and return the IDs of all customers who appear in the visit records but do not appear in the transaction records.

Key Requirements:

  • Identify unique customers: Ensure you are considering unique customer IDs.
  • Distinguish visits from transactions: A customer must have a record in the visit dataset but no record in the transaction dataset.
  • Return customer IDs: The output should be a list or set of customer IDs that meet the criteria.

Expected Behavior:

The algorithm should process both datasets and return a collection of customer IDs. If there are no customers who visited but didn't transact, an empty collection should be returned.

Edge Cases to Consider:

  • Empty datasets: What happens if either the visits or transactions dataset is empty?
  • Customers with multiple visits: A customer might visit multiple times but still not transact. They should be included in the output if they have no transactions.
  • Customers with multiple transactions: These customers should not be included in the output.
  • Customers who only exist in transactions: These customers are irrelevant to the problem and should not affect the output.
  • Data integrity: Assume customer IDs are consistent across datasets.

Examples

Example 1:

Input:
Visits: [101, 102, 103, 101]
Transactions: [101, 103]

Output:
[102]

Explanation:
Customer 101 visited twice and transacted once.
Customer 102 visited once and did not transact.
Customer 103 visited once and transacted once.
Therefore, only customer 102 visited but did not transact.

Example 2:

Input:
Visits: [201, 202, 203, 204]
Transactions: [201, 202, 203, 204]

Output:
[]

Explanation:
All customers who visited also made a transaction. Thus, no customer meets the criteria.

Example 3:

Input:
Visits: [301, 301, 302]
Transactions: []

Output:
[301, 302]

Explanation:
No transactions were made by any customer. Therefore, all customers who visited are considered.

Constraints

  • The number of visits and transactions can range from 0 to 1,000,000.
  • Customer IDs are integers and are positive.
  • The solution should aim for an efficient time complexity, ideally better than O(N*M) where N is the number of visits and M is the number of transactions.

Notes

  • Think about efficient ways to store and query customer IDs from both datasets.
  • Data structures like sets or hash maps can be very helpful here.
  • Consider the distinct customer IDs from the visits dataset. For each of these, check if they exist in the transactions dataset.
Loading editor...
plaintext