← together.ai Interview Insights

together.ai·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Interviewed at together.ai and got a graph theory problem that I've seen before but still managed to overthink in the moment.

Questions Asked (1)

Q1

Given a set of pods where each pod can depend on other pods, detect whether the dependency graph contains a cycle.

Algorithms & Data Structures
Author's notes

I knew this problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the pods and dependencies as a directed graph, then use either DFS with recursion stack or Kahn's algorithm (topological sort) to detect cycles. Explain the trade-offs between the two approaches and discuss how this applies to real-world container orchestration systems like Kubernetes.

Pro tip: Mention that in production systems like Kubernetes, cycle detection is often done during admission control to prevent invalid configurations, and discuss how you'd handle large-scale graphs with millions of pods using iterative approaches to avoid stack overflow.

1. Clarify the problem and constraints

Ask about graph size, whether dependencies are directed, and if there are self-loops or multiple edges. Confirm that a cycle means a pod transitively depends on itself.

2. Choose a cycle detection algorithm

Select between DFS with colors (white/gray/black) or Kahn's algorithm (BFS-based topological sort). Explain why one might be preferred based on graph density or memory constraints.

3. Walk through the algorithm step-by-step

Describe how you'd traverse the graph, track visited nodes, and detect back edges. For DFS, explain the recursion stack; for Kahn's, explain indegree tracking and queue processing.

4. Analyze complexity and edge cases

State time and space complexity (O(V+E) for both). Discuss handling disconnected graphs, empty input, and very deep graphs (iterative DFS to avoid stack overflow).

5. Relate to real-world context

Connect to together.ai's domain: how this applies to dependency resolution in container orchestration, build systems, or microservices. Mention potential optimizations like incremental cycle detection.

Key Points to Mention

  • Directed graph representation (adjacency list vs. adjacency matrix) and its impact on performance
  • DFS with recursion stack vs. Kahn's algorithm: trade-offs in implementation complexity and memory
  • Time and space complexity: O(V+E) time, O(V) space for both approaches
  • Handling disconnected graphs and ensuring all components are checked
  • Iterative DFS to avoid stack overflow in deep graphs, especially for large-scale systems
  • Real-world application: Kubernetes pod dependencies, build systems (e.g., Bazel), or package managers

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