Katkat

Find Business Degrees of Separation

IntuitSoftware Engineer · Technical Screen

Last updated

This question evaluates understanding of graph traversal and shortest-path computation, including modeling business relationships as undirected graphs and interpreting degrees of separation on the shortest path.

Implement a feature for a small-business network.

QuickBooks has data showing business relationships, such as one business regularly buying goods or services from another. Treat each relationship as an undirected connection between two businesses.

Given:

  • A collection of business-to-business relationships, where each relationship connects two business IDs or names.
  • A source business.
  • A target business.

Return the shortest relationship path between the source and target if one exists, along with the degree of separation.

For this problem, define the degree of separation as the number of intermediate businesses on the shortest path. Therefore, if the shortest path is A -> B -> C, then A and C have degree of separation 1.

Example:

Relationships:

A <-> B
B <-> C

Query:

source = A
target = C

Expected result:

path = [A, B, C]
degree = 1

If multiple shortest paths exist, returning any one of them is acceptable unless otherwise specified. If no path exists, return an appropriate empty result such as null, an empty path, or degree -1, depending on the function contract you define.