My first instinct was a hashmap where each customer maps to a set of everyone they've transacted with.
Start by clarifying requirements: transaction volume, query frequency, and whether the stream is real-time or batch. Then propose a data model that stores each unique customer pair in a hash set for O(1) query, and discuss trade-offs like memory usage and scalability.
Pro tip: Mention that you would normalize the pair (e.g., sort customer IDs) to avoid duplicates and ensure consistent lookups. Also, consider using a probabilistic data structure like a Bloom filter if memory is constrained, but be clear about false positives.
Ask about expected transaction rate, number of customers, query frequency, and memory constraints to guide design choices.
Propose storing each unique customer pair in a hash set, using a normalized key (e.g., min-max or sorted tuple) to ensure consistency.
For each transaction, extract the two customer IDs, normalize the pair, and insert into the set if not already present.
For a query, normalize the given pair and check membership in the set, returning true if present.
Address memory usage (O(P) where P is number of unique pairs), potential for distributed storage, and alternatives like Bloom filters for approximate answers.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.