← Salesforce questions
CodingReported in a candidate post, Feb 2025

Hops between nodes for queries on a directed graph

Filed under Salesforce

Given a directed graph as a list of edges and a list of queries (a, b), return for each query the number of hops (edges on the shortest path) from a to b, or -1 if b is not reachable from a.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Salesforce questions

Collected from public candidate posts and coding forums. Updated Nov 2026.