← LinkedIn Interview Insights

LinkedIn·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

LinkedIn coding round for a software engineer role. One problem, pretty involved, centered on graph traversal with some file parsing thrown in. Felt like a solid mid-level systems-thinking question dressed up as a coding exercise.

Questions Asked (1)

Q1

You're given a JSON file describing services and their dependencies. A specific service goes down. Write code to parse the file, build a dependency graph, and find all services transitively affected. Be ready to talk about time complexity and how you'd handle cycles.

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

The JSON parsing part was fine but I fumbled a bit explaining why I chose BFS over DFS.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the JSON structure and whether the graph is directed (dependencies point from service to its dependencies). Then outline a solution using DFS or BFS to traverse the graph from the failed service, collecting all reachable nodes. Discuss time and space complexity, and address cycle handling with a visited set.

Pro tip: Mention that in production systems, you'd likely use a reverse dependency graph (dependents rather than dependencies) to quickly find affected services, and consider incremental updates or caching for performance.

1. Clarify requirements and assumptions

Ask about the JSON schema, direction of dependencies, and whether the graph is a DAG. Confirm that 'affected' means all services that directly or indirectly depend on the failed service.

2. Design the graph representation

Choose an adjacency list (e.g., Map<String, List<String>>) for efficient traversal. If dependencies point from service to its dependencies, build a reverse graph to find dependents.

3. Implement traversal algorithm

Use DFS or BFS starting from the failed service, marking visited nodes to avoid cycles. Collect all reachable services as the affected set.

4. Analyze complexity and edge cases

State time complexity O(V+E) and space O(V+E). Discuss handling cycles with a visited set, and consider disconnected graphs or missing services.

5. Discuss optimizations and trade-offs

Mention alternative approaches like topological sort if the graph is a DAG, or using union-find for dynamic connectivity. Highlight trade-offs between precomputation and on-the-fly traversal.

Key Points to Mention

  • Graph representation: adjacency list vs. adjacency matrix, and why adjacency list is preferred for sparse graphs.
  • Traversal algorithm: DFS (recursive/iterative) or BFS, with a visited set to handle cycles.
  • Time and space complexity: O(V+E) for both, where V is number of services and E is number of dependencies.
  • Cycle handling: using a visited set during traversal prevents infinite loops; alternatively, detect cycles upfront with DFS coloring.
  • Direction of dependencies: clarify whether edges represent 'depends on' or 'depended on by', and build the graph accordingly.
  • Production considerations: reverse dependency graph for quick lookups, caching, and incremental updates for large-scale systems.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.