Square·Software Engineer·Technical Phone Screen
- Design a class to record transactions between pairs of customers and answer whether two customers have ever been part of the same connected component in the transaction graph.
- Extend your solution to return everyone reachable from a given customer through any chain of transactions, excluding the customer themselves.
- Further extend the network query to accept a degree limit, returning only customers within at most N hops from the given person.
“The union-find angle came to me pretty fast, which was good.”